From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 02/11] shared/sec: rename struct mac_classification
Date: Mon, 24 Jun 2019 11:24:55 +0900 [thread overview]
Message-ID: <20190624022504.18752-3-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190624022504.18752-1-yasufum.o@gmail.com>
From: Yasufumi Ogawa <yasufum.o@gmail.com>
Struct `mac_classification` defines a set of attirbutes for
classification. This update is to rename the struct to `mac_classifier`
and also its members.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/shared/secondary/spp_worker_th/vf_deps.h | 27 ++++-----
src/vf/classifier_mac.c | 61 ++++++++++----------
2 files changed, 39 insertions(+), 49 deletions(-)
diff --git a/src/shared/secondary/spp_worker_th/vf_deps.h b/src/shared/secondary/spp_worker_th/vf_deps.h
index fd0dc5d..c6016b8 100644
--- a/src/shared/secondary/spp_worker_th/vf_deps.h
+++ b/src/shared/secondary/spp_worker_th/vf_deps.h
@@ -12,19 +12,12 @@
/** Number of VLAN ID */
#define NOF_VLAN 4096
-/* mac address classification */
-struct mac_classification {
- /* hash table keeps classification */
- struct rte_hash *classification_tab;
-
- /* number of valid classification */
- int num_active_classified;
-
- /* index of valid classification */
- int active_classifieds[RTE_MAX_ETHPORTS];
-
- /* index of default classification */
- int default_classified;
+/* Classifier for MAC addresses. */
+struct mac_classifier {
+ struct rte_hash *cls_tbl; /* Hash table for MAC classification. */
+ int nof_cls_ports; /* Num of ports classified validly. */
+ int cls_ports[RTE_MAX_ETHPORTS]; /* Ports for classification. */
+ int default_cls_idx; /* Default index for classification. */
};
/* classified data (destination port, target packets, etc) */
@@ -54,7 +47,7 @@ struct component_info {
int mac_addr_entry; /* mac address entry flag */
/* mac address classification per vlan-id */
- struct mac_classification *mac_classifications[NOF_VLAN];
+ struct mac_classifier *mac_classifications[NOF_VLAN];
int n_classified_data_tx; /* number of transmission ports */
struct classified_data classified_data_rx; /* RX handled by cls */
@@ -64,13 +57,13 @@ struct component_info {
/* free mac classification instance. */
static inline void
-free_mac_classification(struct mac_classification *mac_cls)
+free_mac_classification(struct mac_classifier *mac_cls)
{
if (mac_cls == NULL)
return;
- if (mac_cls->classification_tab != NULL)
- rte_hash_free(mac_cls->classification_tab);
+ if (mac_cls->cls_tbl != NULL)
+ rte_hash_free(mac_cls->cls_tbl);
rte_free(mac_cls);
}
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index 76dd9e7..5398d25 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -272,23 +272,23 @@ is_used_mng_info(const struct management_info *mng_info)
}
/* create mac classification instance. */
-static struct mac_classification *
+static struct mac_classifier *
create_mac_classification(void)
{
- struct mac_classification *mac_cls;
+ struct mac_classifier *mac_cls;
char hash_tab_name[HASH_TABLE_NAME_BUF_SZ];
struct rte_hash **mac_cls_tab;
- mac_cls = (struct mac_classification *)rte_zmalloc(
- NULL, sizeof(struct mac_classification), 0);
+ mac_cls = (struct mac_classifier *)rte_zmalloc(
+ NULL, sizeof(struct mac_classifier), 0);
if (unlikely(mac_cls == NULL))
return NULL;
- mac_cls->num_active_classified = 0;
- mac_cls->default_classified = -1;
+ mac_cls->nof_cls_ports = 0;
+ mac_cls->default_cls_idx = -1;
- mac_cls_tab = &mac_cls->classification_tab;
+ mac_cls_tab = &mac_cls->cls_tbl;
/* make hash table name(require uniqueness between processes) */
sprintf(hash_tab_name, "cmtab_%07x%02hx",
@@ -328,7 +328,7 @@ init_component_info(struct component_info *cmp_info,
{
int ret = SPP_RET_NG;
int i;
- struct mac_classification *mac_cls;
+ struct mac_classifier *mac_cls;
struct ether_addr eth_addr;
char mac_addr_str[ETHER_ADDR_STR_BUF_SZ];
struct classified_data *clsd_data_rx = &cmp_info->classified_data_rx;
@@ -385,8 +385,7 @@ init_component_info(struct component_info *cmp_info,
mac_cls = cmp_info->mac_classifications[vid];
/* store active tx_port that associate with mac address */
- mac_cls->active_classifieds[
- mac_cls->num_active_classified++] = i;
+ mac_cls->cls_ports[mac_cls->nof_cls_ports++] = i;
/* mac address entry flag set */
cmp_info->mac_addr_entry = 1;
@@ -394,7 +393,7 @@ init_component_info(struct component_info *cmp_info,
/* store default classified */
if (unlikely(tx_port->cls_attrs.mac_addr ==
SPP_DEFAULT_CLASSIFIED_DMY_ADDR)) {
- mac_cls->default_classified = i;
+ mac_cls->default_cls_idx = i;
RTE_LOG(INFO, SPP_CLASSIFIER_MAC,
"default classified. vid=%hu, "
"iface_type=%d, iface_no=%d, "
@@ -412,7 +411,7 @@ init_component_info(struct component_info *cmp_info,
ether_format_addr(mac_addr_str, sizeof(mac_addr_str),
ð_addr);
- ret = rte_hash_add_key_data(mac_cls->classification_tab,
+ ret = rte_hash_add_key_data(mac_cls->cls_tbl,
(void *)ð_addr, (void *)(long)i);
if (unlikely(ret < 0)) {
RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
@@ -518,7 +517,7 @@ push_packet(struct rte_mbuf *pkt, struct classified_data *clsd_data)
static inline int
get_general_default_classified_index(struct component_info *cmp_info)
{
- struct mac_classification *mac_cls;
+ struct mac_classifier *mac_cls;
mac_cls = cmp_info->mac_classifications[VLAN_UNTAGGED_VID];
if (unlikely(mac_cls == NULL)) {
@@ -527,7 +526,7 @@ get_general_default_classified_index(struct component_info *cmp_info)
return SPP_RET_NG;
}
- return mac_cls->default_classified;
+ return mac_cls->default_cls_idx;
}
/* handle L2 multicast(include broadcast) packet */
@@ -537,7 +536,7 @@ handle_l2multicast_packet(struct rte_mbuf *pkt,
struct classified_data *clsd_data)
{
int i;
- struct mac_classification *mac_cls;
+ struct mac_classifier *mac_cls;
uint16_t vid = get_vid(pkt);
int gen_def_clsd_idx = get_general_default_classified_index(cmp_info);
int n_act_clsd;
@@ -545,7 +544,7 @@ handle_l2multicast_packet(struct rte_mbuf *pkt,
/* select mac address classification by vid */
mac_cls = cmp_info->mac_classifications[vid];
if (unlikely(mac_cls == NULL ||
- mac_cls->num_active_classified == 0)) {
+ mac_cls->nof_cls_ports == 0)) {
/* specific vlan is not registered
* use untagged's default(as general default)
*/
@@ -564,18 +563,16 @@ handle_l2multicast_packet(struct rte_mbuf *pkt,
}
/* add to mbuf's refcnt */
- n_act_clsd = mac_cls->num_active_classified;
+ n_act_clsd = mac_cls->nof_cls_ports;
if (gen_def_clsd_idx >= 0 && vid != VLAN_UNTAGGED_VID)
++n_act_clsd;
rte_mbuf_refcnt_update(pkt, (int16_t)(n_act_clsd - 1));
/* transmit to specific segment & general default */
- for (i = 0; i < mac_cls->num_active_classified; i++) {
- LOG_CLS((long)mac_cls->active_classifieds[i],
- pkt, cmp_info, clsd_data);
- push_packet(pkt, clsd_data +
- (long)mac_cls->active_classifieds[i]);
+ for (i = 0; i < mac_cls->nof_cls_ports; i++) {
+ LOG_CLS((long)mac_cls->cls_ports[i], pkt, cmp_info, clsd_data);
+ push_packet(pkt, clsd_data + (long)mac_cls->cls_ports[i]);
}
if (gen_def_clsd_idx >= 0 && vid != VLAN_UNTAGGED_VID) {
@@ -592,7 +589,7 @@ select_classified_index(const struct rte_mbuf *pkt,
int ret;
struct ether_hdr *eth;
void *lookup_data;
- struct mac_classification *mac_cls;
+ struct mac_classifier *mac_cls;
uint16_t vid;
eth = rte_pktmbuf_mtod(pkt, struct ether_hdr *);
@@ -607,7 +604,7 @@ select_classified_index(const struct rte_mbuf *pkt,
}
/* find in table (by destination mac address) */
- ret = rte_hash_lookup_data(mac_cls->classification_tab,
+ ret = rte_hash_lookup_data(mac_cls->cls_tbl,
(const void *)ð->d_addr, &lookup_data);
if (ret >= 0) {
LOG_DBG(cmp_info->name, "Mac address is registered. "
@@ -624,7 +621,7 @@ select_classified_index(const struct rte_mbuf *pkt,
return -2;
/* if default is not set, use untagged's default */
- if (unlikely(mac_cls->default_classified < 0 &&
+ if (unlikely(mac_cls->default_cls_idx < 0 &&
vid != VLAN_UNTAGGED_VID)) {
LOG_DBG(cmp_info->name, "Vid's default is not set. "
"use general default. vid=%hu\n", vid);
@@ -633,7 +630,7 @@ select_classified_index(const struct rte_mbuf *pkt,
/* use default */
LOG_DBG(cmp_info->name, "Use vid's default. vid=%hu\n", vid);
- return mac_cls->default_classified;
+ return mac_cls->default_cls_idx;
}
/*
@@ -865,7 +862,7 @@ static void
mac_classification_iterate_table(
struct spp_iterate_classifier_table_params *params,
uint16_t vid,
- struct mac_classification *mac_cls,
+ struct mac_classifier *mac_cls,
__rte_unused struct component_info *cmp_info,
struct classified_data *clsd_data)
{
@@ -881,13 +878,13 @@ mac_classification_iterate_table(
if (unlikely(vid == VLAN_UNTAGGED_VID))
type = SPP_CLASSIFIER_TYPE_MAC;
- if (mac_cls->default_classified >= 0) {
+ if (mac_cls->default_cls_idx >= 0) {
port.iface_type = (clsd_data +
- mac_cls->default_classified)->iface_type;
+ mac_cls->default_cls_idx)->iface_type;
port.iface_no = (clsd_data +
- mac_cls->default_classified)->iface_no_global;
+ mac_cls->default_cls_idx)->iface_no_global;
- LOG_ENT((long)mac_cls->default_classified,
+ LOG_ENT((long)mac_cls->default_cls_idx,
vid,
SPP_DEFAULT_CLASSIFIED_SPEC_STR,
cmp_info, clsd_data);
@@ -902,7 +899,7 @@ mac_classification_iterate_table(
next = 0;
while (1) {
- ret = rte_hash_iterate(mac_cls->classification_tab,
+ ret = rte_hash_iterate(mac_cls->cls_tbl,
&key, &data, &next);
if (unlikely(ret < 0))
--
2.17.1
next prev parent reply other threads:[~2019-06-24 2:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 2:24 [spp] [PATCH 00/11] Refactor libs for classifier in spp_vf yasufum.o
2019-06-24 2:24 ` [spp] [PATCH 01/11] shared/sec: refactor defines of VLAN " yasufum.o
2019-06-24 2:24 ` yasufum.o [this message]
2019-06-24 2:24 ` [spp] [PATCH 03/11] shared/sec: refactor comments in vf_deps.h yasufum.o
2019-06-24 2:24 ` [spp] [PATCH 04/11] shared/sec: rename struct classified_data yasufum.o
2019-06-24 2:24 ` [spp] [PATCH 05/11] shared/sec: revise usage of term component_info yasufum.o
2019-06-24 2:24 ` [spp] [PATCH 06/11] shared/sec: revise members of struct cls_port_info yasufum.o
2019-06-24 2:25 ` [spp] [PATCH 07/11] shared/sec: rename func free_mac_classification yasufum.o
2019-06-24 2:25 ` [spp] [PATCH 08/11] shared/sec: refactor updating classifier info yasufum.o
2019-06-24 2:25 ` [spp] [PATCH 09/11] shared/sec: refactor updating forwarder yasufum.o
2019-06-24 2:25 ` [spp] [PATCH 10/11] shared/sec: refactor getting classifier status yasufum.o
2019-06-24 2:25 ` [spp] [PATCH 11/11] shared/sec: refactor setup cls table stat in JSON yasufum.o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190624022504.18752-3-yasufum.o@gmail.com \
--to=yasufum.o@gmail.com \
--cc=ferruh.yigit@intel.com \
--cc=spp@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).