Commit 17580b18 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/wrsw_rtud: move shm definitions to libwr rtu_shm.h

Move definitions of structures used in rtud's shm to rtu_shm.h in libwr.
Move few more definitions to rtu_shm.h and update .h files relaying on moved
structures/definitions.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent f44ca1c7
#ifndef __LIBWR_RTU_SHMEM_H__
#define __LIBWR_RTU_SHMEM_H__
#include <stdint.h>
#define RTU_ENTRIES 2048
#define RTU_BUCKETS 4
#define HTAB_ENTRIES ((RTU_ENTRIES)/(RTU_BUCKETS))
#define LAST_HTAB_ENTRY ((HTAB_ENTRIES)-1)
#define LAST_RTU_BUCKET (RTU_BUCKETS-1)
#define ETH_ALEN 6
#define ETH_ALEN_STR 18
/* RTU entry address */
struct rtu_addr {
int hash;
int bucket;
};
/**
* \brief RTU Filtering Database Entry Object
*/
struct filtering_entry {
struct rtu_addr addr; /* address of self in the RTU hashtable */
int valid; /* bit: 1 = entry is valid, 0: entry is
* invalid (empty) */
int end_of_bucket; /* bit: 1 = last entry in current bucket,
* stop search at this point */
int is_bpdu; /* bit: 1 = BPDU (or other non-STP-dependent
* packet) */
uint8_t mac[ETH_ALEN]; /* MAC address (for searching the bucketed
* hashtable) */
uint8_t fid; /* Filtering database ID (for searching the
* bucketed hashtable) */
uint32_t port_mask_src; /* port mask for source MAC addresses. Bits
* set to 1 indicate that packet having this
* MAC address can be forwarded from these
* corresponding ports. Ports having their
* bits set to 0 shall drop the packet. */
uint32_t port_mask_dst; /* port mask for destination MAC address. Bits
* set to 1 indicate to which physical ports
* the packet with matching destination MAC
* address shall be routed */
int drop_when_source; /* bit: 1 = drop the packet when source
* address matches */
int drop_when_dest; /* bit: 1 = drop the packet when destination
* address matches */
int drop_unmatched_src_ports; /* bit: 1 = drop the packet when it
* comes from source port different
* than specified in port_mask_src */
uint32_t last_access_t; /* time of last access to the rule
* (for aging) */
int force_remove; /* when true, the entry is to be removed
* immediately (aged out or destination port
* went down) */
uint8_t prio_src; /* priority (src MAC) */
int has_prio_src; /* priority value valid */
int prio_override_src; /* priority override (force per-MAC priority) */
uint8_t prio_dst; /* priority (dst MAC) */
int has_prio_dst; /* priority value valid */
int prio_override_dst; /* priority override (force per-MAC priority) */
int dynamic;
int age;
};
/**
* \brief RTU VLAN registration entry object
*/
struct vlan_table_entry {
uint32_t port_mask; /* VLAN port mask:
* 1 = ports assigned to this VLAN */
uint8_t fid; /* Filtering Database Identifier */
uint8_t prio; /* VLAN priority */
int has_prio; /* priority defined; */
int prio_override; /* priority override
* (force per-VLAN priority) */
int drop; /* 1: drop the packet (VLAN not registered) */
};
#endif /* __LIBWR_RTU_SHMEM_H__ */
......@@ -32,9 +32,7 @@
#include <stdint.h>
#include <string.h>
#define ETH_ALEN 6
#define ETH_ALEN_STR 18
#include <libwr/rtu_shmem.h>
/**
* \brief Check whether two mac addresses are equal.
......
......@@ -35,14 +35,8 @@
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <libwr/rtu_shmem.h>
#include "mac.h"
#define RTU_ENTRIES 2048
#define RTU_BUCKETS 4
#define HTAB_ENTRIES ((RTU_ENTRIES)/(RTU_BUCKETS))
#define LAST_HTAB_ENTRY ((HTAB_ENTRIES)-1)
#define LAST_RTU_BUCKET (RTU_BUCKETS-1)
#define ENTRY_WORDS 8
......@@ -64,12 +58,6 @@
// Keeping in mind year 2038
#define time_after(a,b) ((long)(b) - (long)(a) < 0)
/* RTU entry address */
struct rtu_addr {
int hash;
int bucket;
};
/**
* \brief RTU request: input for the RTU
*/
......@@ -85,71 +73,6 @@ struct rtu_request {
int has_prio; // non-zero: priority present, 0:no priority defined
};
/**
* \brief RTU Filtering Database Entry Object
*/
struct filtering_entry {
struct rtu_addr addr; // address of self in the RTU hashtable
int valid; // bit: 1 = entry is valid, 0: entry is
// invalid (empty)
int end_of_bucket; // bit: 1 = last entry in current bucket, stop
// search at this point
int is_bpdu; // bit: 1 = BPDU (or other non-STP-dependent
// packet)
uint8_t mac[ETH_ALEN]; // MAC address (for searching the bucketed
// hashtable)
uint8_t fid; // Filtering database ID (for searching the
// bucketed hashtable)
uint32_t port_mask_src; // port mask for source MAC addresses. Bits
// set to 1 indicate that packet having this
// MAC address can be forwarded from these
// corresponding ports. Ports having their
// bits set to 0 shall drop the packet.
uint32_t port_mask_dst; // port mask for destination MAC address. Bits
// set to 1 indicate to which physical ports
// the packet with matching destination MAC
// address shall be routed
int drop_when_source; // bit: 1 = drop the packet when source
// address matches
int drop_when_dest; // bit: 1 = drop the packet when destination
// address matches
int drop_unmatched_src_ports; // bit: 1 = drop the packet when it comes from
// source port different than specified in
// port_mask_src
uint32_t last_access_t; // time of last access to the rule (for aging)
int force_remove; // when true, the entry is to be removed immediately (
// aged out or destination port went down)
uint8_t prio_src; // priority (src MAC)
int has_prio_src; // priority value valid
int prio_override_src; // priority override (force per-MAC priority)
uint8_t prio_dst; // priority (dst MAC)
int has_prio_dst; // priority value valid
int prio_override_dst; // priority override (force per-MAC priority)
int dynamic;
int age;
};
/**
* \brief RTU VLAN registration entry object
*/
struct vlan_table_entry {
uint32_t port_mask; // VLAN port mask: 1 = ports assigned to this VLAN
uint8_t fid; // Filtering Database Identifier
uint8_t prio; // VLAN priority
int has_prio; // priority defined;
int prio_override; // priority override (force per-VLAN priority)
int drop; // 1: drop the packet (VLAN not registered)
};
/**
* \brief Copies src filtering entry body into dst filtering entry body.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment