From: x-fn-spp@sl.ntt-tx.co.jp
To: spp@dpdk.org
Subject: [spp] [PATCH 35/57] spp_vf: add proc on receiving l2 multicast
Date: Thu, 28 Dec 2017 13:55:42 +0900 [thread overview]
Message-ID: <201712280456.vBS4u7dD011092@imss03.silk.ntt-tx.co.jp> (raw)
In-Reply-To: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp>
From: Hiroyuki Nakamura <nakamura.hioryuki@po.ntt-tx.co.jp>
Add two functions for L2 multicast packets
* Transmit them to multiple ports.
* Transmit them to default port when there is no classification.
Add followings to transmit packets to multiple ports:
* Make a list of ports corresponding to MAC addresses.
* Transmit packets of multicast address(I/G bit is 1) to all the ports
listed.
Add followings to transmit packets to default port:
* Set default port via command.
* Use default port when there is no classification.
Signed-off-by: Daiki Yamashita <yamashita.daiki.z01@as.ntt-tx.co.jp>
Signed-off-by: Yasufum Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/vf/classifier_mac.c | 119 ++++++++++++++++++++++++++++++++++++++----------
src/vf/command_dec.c | 4 ++
src/vf/spp_config.c | 6 +++
src/vf/spp_config.h | 4 ++
4 files changed, 108 insertions(+), 25 deletions(-)
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index cc4af2b..e69347f 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -64,6 +64,9 @@ static const size_t ETHER_ADDR_STR_BUF_SZ =
/* classifier information */
struct classifier_mac_info {
struct rte_hash *classifier_table;
+ int num_active_classified;
+ int active_classifieds[RTE_MAX_ETHPORTS];
+ int default_classified;
};
/* classifier management information */
@@ -91,27 +94,46 @@ static struct classifier_mac_mng_info g_classifier_mng_info[RTE_MAX_LCORE];
but since we want to start at 0. */
static rte_atomic16_t g_hash_table_count = RTE_ATOMIC16_INIT(0xff);
-/* initialize classifier table. */
+/* initialize classifier information. */
static int
-init_classifier_table(struct rte_hash **classifier_table,
+init_classifier_info(struct classifier_mac_info *classifier_info,
const struct spp_core_info *core_info)
{
int ret = -1;
int i;
+ struct rte_hash **classifier_table = &classifier_info->classifier_table;
struct ether_addr eth_addr;
char mac_addr_str[ETHER_ADDR_STR_BUF_SZ];
rte_hash_reset(*classifier_table);
+ classifier_info->num_active_classified = 0;
+ classifier_info->default_classified = -1;
for (i = 0; i < core_info->num_tx_port; i++) {
if (core_info->tx_ports[i].mac_addr == 0) {
continue;
}
+ /* store active tx_port that associate with mac address */
+ classifier_info->active_classifieds[classifier_info->
+ num_active_classified++] = i;
+
+ /* store default classified */
+ if (unlikely(core_info->tx_ports[i].mac_addr ==
+ SPP_CONFIG_DEFAULT_CLASSIFIED_DMY_ADDR)) {
+ classifier_info->default_classified = i;
+ RTE_LOG(INFO, SPP_CLASSIFIER_MAC, "default classified. "
+ "if_type=%d, if_no=%d, dpdk_port=%d\n",
+ core_info->tx_ports[i].if_type,
+ core_info->tx_ports[i].if_no,
+ core_info->tx_ports[i].dpdk_port);
+ continue;
+ }
+
+ /* add entry to classifier mac table */
rte_memcpy(ð_addr, &core_info->tx_ports[i].mac_addr, ETHER_ADDR_LEN);
ether_format_addr(mac_addr_str, sizeof(mac_addr_str), ð_addr);
- /* add entry to classifier mac table */
ret = rte_hash_add_key_data(*classifier_table,
(void*)ð_addr, (void*)(long)i);
if (unlikely(ret < 0)) {
@@ -186,11 +208,9 @@ init_classifier(const struct spp_core_info *core_info,
}
}
- /* populate the hash at reference table */
- classifier_mac_table = &classifier_mng_info->info[classifier_mng_info->ref_index].
- classifier_table;
-
- ret = init_classifier_table(classifier_mac_table, core_info);
+ /* populate the classifier information at reference */
+ ret = init_classifier_info(&classifier_mng_info->
+ info[classifier_mng_info->ref_index], core_info);
if (unlikely(ret != 0)) {
RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
"Cannot initialize classifer mac table. ret=%d\n", ret);
@@ -252,6 +272,42 @@ transmit_packet(struct classified_data *classified_data)
classified_data->num_pkt = 0;
}
+/* set mbuf pointer to tx buffer
+ and transmit packet, if buffer is filled */
+static inline void
+push_packet(struct rte_mbuf *pkt, struct classified_data *classified_data)
+{
+ classified_data->pkts[classified_data->num_pkt++] = pkt;
+
+ /* transmit packet, if buffer is filled */
+ if (unlikely(classified_data->num_pkt == MAX_PKT_BURST)) {
+ RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC,
+ "transimit packets (buffer is filled). "
+ "if_type=%d, if_no=%d, tx_port=%hhd, num_pkt=%hu\n",
+ classified_data->if_type,
+ classified_data->if_no,
+ classified_data->tx_port,
+ classified_data->num_pkt);
+ transmit_packet(classified_data);
+ }
+}
+
+/* handle L2 multicast(include broadcast) packet */
+static inline void
+handle_l2multicast_packet(struct rte_mbuf *pkt,
+ struct classifier_mac_info *classifier_info,
+ struct classified_data *classified_data)
+{
+ int i;
+
+ rte_mbuf_refcnt_update(pkt, classifier_info->num_active_classified);
+
+ for (i= 0; i < classifier_info->num_active_classified; i++) {
+ push_packet(pkt, classified_data +
+ (long)classifier_info->active_classifieds[i]);
+ }
+}
+
/* classify packet by destination mac address,
and transmit packet (conditional). */
static inline void
@@ -262,7 +318,6 @@ classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx,
int ret;
int i;
struct ether_hdr *eth;
- struct classified_data *cd;
void *lookup_data;
char mac_addr_str[ETHER_ADDR_STR_BUF_SZ];
@@ -272,27 +327,41 @@ classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx,
/* find in table (by destination mac address)*/
ret = rte_hash_lookup_data(classifier_info->classifier_table,
(const void*)ð->d_addr, &lookup_data);
- if (unlikely(ret < 0)) {
- ether_format_addr(mac_addr_str, sizeof(mac_addr_str), ð->d_addr);
- RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
- "unknown mac address. ret=%d, mac_addr=%s\n", ret, mac_addr_str);
- rte_pktmbuf_free(rx_pkts[i]);
- continue;
- }
+ if (ret < 0) {
+ /* L2 multicast(include broadcast) ? */
+ if (unlikely(is_multicast_ether_addr(ð->d_addr))) {
+ RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC,
+ "multicast mac address.\n");
+ handle_l2multicast_packet(rx_pkts[i],
+ classifier_info, classified_data);
+ continue;
+ }
- /* set mbuf pointer to tx buffer */
- cd = classified_data + (long)lookup_data;
- cd->pkts[cd->num_pkt++] = rx_pkts[i];
+ /* if no default, drop packet */
+ if (unlikely(classifier_info->default_classified == -1)) {
+ ether_format_addr(mac_addr_str,
+ sizeof(mac_addr_str), ð->d_addr);
+ RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
+ "unknown mac address. "
+ "ret=%d, mac_addr=%s\n",
+ ret, mac_addr_str);
+ rte_pktmbuf_free(rx_pkts[i]);
+ continue;
+ }
- /* transmit packet, if buffer is filled */
- if (unlikely(cd->num_pkt == MAX_PKT_BURST)) {
+ /* to default classifed */
RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC,
- "transimit packets (buffer is filled). index=%ld, num_pkt=%hu\n", (long)lookup_data, cd->num_pkt);
- transmit_packet(cd);
+ "to default classified.\n");
+ lookup_data = (void *)(long)classifier_info->default_classified;
}
+
+ /* set mbuf pointer to tx buffer
+ and transmit packet, if buffer is filled */
+ push_packet(rx_pkts[i], classified_data + (long)lookup_data);
}
}
+/* change update index at classifier management information */
static inline void
change_update_index(struct classifier_mac_mng_info *classifier_mng_info, unsigned int lcore_id)
{
@@ -322,8 +391,8 @@ spp_classifier_mac_update(struct spp_core_info *core_info)
RTE_LOG(INFO, SPP_CLASSIFIER_MAC,
"Core[%u] Start update component.\n", lcore_id);
- /* initialize update side classifier table */
- ret = init_classifier_table(&classifier_info->classifier_table, core_info);
+ /* initialize update side classifier information */
+ ret = init_classifier_info(classifier_info, core_info);
if (unlikely(ret != 0)) {
RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
"Cannot update classifer mac. ret=%d\n", ret);
diff --git a/src/vf/command_dec.c b/src/vf/command_dec.c
index d3ff27a..3295618 100644
--- a/src/vf/command_dec.c
+++ b/src/vf/command_dec.c
@@ -158,6 +158,10 @@ decode_mac_addr_str_value(void *output, const json_t *value_obj,
int ret = -1;
const char* str_val = json_string_value(value_obj);
+ /* if default specification, convert to internal dummy address */
+ if (unlikely(strcmp(str_val, SPP_CONFIG_DEFAULT_CLASSIFIED_SPEC_STR) == 0))
+ str_val = SPP_CONFIG_DEFAULT_CLASSIFIED_DMY_ADDR_STR;
+
ret = spp_config_change_mac_str_to_int64(str_val);
if (unlikely(ret == -1)) {
RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad mac address string. val=%s\n",
diff --git a/src/vf/spp_config.c b/src/vf/spp_config.c
index 8c82c13..663a609 100644
--- a/src/vf/spp_config.c
+++ b/src/vf/spp_config.c
@@ -319,6 +319,12 @@ config_load_classifier_table(const json_t *obj,
return -1;
}
+ /* デフォルト転送先指定であれば内部流通用ダミーアドレスに変換 */
+ if (unlikely(strcmp(tmp_table->mac_addr_str,
+ SPP_CONFIG_DEFAULT_CLASSIFIED_SPEC_STR) == 0))
+ strcpy(tmp_table->mac_addr_str,
+ SPP_CONFIG_DEFAULT_CLASSIFIED_DMY_ADDR_STR);
+
/* MACアドレス数値変換 */
int64_t ret_mac64 = spp_config_change_mac_str_to_int64(
tmp_table->mac_addr_str);
diff --git a/src/vf/spp_config.h b/src/vf/spp_config.h
index 7945807..ac2bc55 100644
--- a/src/vf/spp_config.h
+++ b/src/vf/spp_config.h
@@ -15,6 +15,10 @@
#define SPP_CONFIG_CORE_MAX 64
#define SPP_CONFIG_PATH_LEN 1024
+#define SPP_CONFIG_DEFAULT_CLASSIFIED_SPEC_STR "default"
+#define SPP_CONFIG_DEFAULT_CLASSIFIED_DMY_ADDR_STR "00:00:00:00:00:01"
+#define SPP_CONFIG_DEFAULT_CLASSIFIED_DMY_ADDR 0x010000000000
+
/*
* Process type for each CORE
*/
--
1.9.1
next prev parent reply other threads:[~2017-12-28 4:56 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-25 4:41 [spp] Proposal - spp_vf(SR-IOV like feature) addition to SPP Nakamura Hioryuki
2017-12-26 1:54 ` Yasufumi Ogawa
2017-12-28 4:55 ` [spp] [PATCH 01/57] spp_vf: add vf functions x-fn-spp
2017-12-28 8:49 ` Yasufumi Ogawa
2017-12-28 4:55 ` [spp] [PATCH 02/57] spp_vf: support multi process x-fn-spp
2018-02-07 16:50 ` Ferruh Yigit
2018-02-08 1:21 ` Yasufumi Ogawa
2018-02-08 6:44 ` [spp] [spp 02168] " Nakamura Hioryuki
2017-12-28 4:55 ` [spp] [PATCH 03/57] spp_vf: comment out check of using cores x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 04/57] spp_vf: modify classifier for upd command x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 05/57] spp_vf: add procedure that mac address is null x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 06/57] spp_vf: change config format for upd command x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 07/57] spp_vf: fix compiler warning in classifier_mac.c x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 08/57] spp_vf: modify data struct for upd command x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 09/57] spp_vf: add functions of command acceptance x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 10/57] spp_vf: add command acceptance calling x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 11/57] spp_vf: fix compiler warning in command_proc.c x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 12/57] " x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 13/57] spp_vf: refactor command acceptance/decode x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 14/57] spp_vf: fix return value overwrite problem x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 15/57] spp_vf: initialize message buffer x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 16/57] spp_vf: add const keyword to parameter x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 17/57] spp_vf: fix wrong comparison operator x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 18/57] spp_vf: fix wrong variable to be assigned x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 19/57] spp_vf: refactor parsing server ip address x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 20/57] spp_vf: fix error in command decode x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 21/57] spp_vf: fix comparison operator in spp_vf.c x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 22/57] spp_vf: check upper limit to the number of process x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 23/57] spp_vf: display usage message x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 24/57] spp_vf: split command processing source file x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 25/57] spp_vf: add new log and line break x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 26/57] spp_vf: support get-process-id command x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 27/57] spp_vf: update socket creation procedure x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 28/57] spp_vf: change log level and add line break x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 29/57] spp_vf: replace unsupported jansson api x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 30/57] spp_vf: change order of command result in json object x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 31/57] spp_vf: use prediction keywords x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 32/57] spp_vf: fix wrong comparison x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 33/57] spp_vf: update sending error status x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 34/57] spp_vf: modify conditional statement x-fn-spp
2017-12-28 4:55 ` x-fn-spp [this message]
2017-12-28 4:55 ` [spp] [PATCH 36/57] spp_vf: extend limit on number of usable cores x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 37/57] spp_vf: add restart procedure for vhost client x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 38/57] spp_vf: fix classifier mbuf handling x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 39/57] spp_vf: add status command x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 40/57] spp_vf: add output source information in error log x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 41/57] spp_vf: change function names x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 42/57] spp_vf: change how to request commands x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 43/57] spp_vf: update command decode procedure x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 44/57] spp_vf: remove debug log output procedures x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 45/57] spp_vf: improve command_decoder program code x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 46/57] spp_vf: fix a bug in status command x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 47/57] spp_vf: add spp_vf.py instead of spp.py x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 48/57] spp_vf: refactor for commnets in spp_vf.c x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 49/57] spp_vf: refactor comments in classifier_mac.c x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 50/57] spp_vf: refactor comments in spp_forward.c x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 51/57] spp_vf: refactor for commnets in spp_config.c x-fn-spp
2017-12-28 4:55 ` [spp] [PATCH 52/57] spp_vf: refactor no self-explanatory comments x-fn-spp
2017-12-28 4:56 ` [spp] [PATCH 53/57] spp_vf: correct typo of function name x-fn-spp
2017-12-28 4:56 ` [spp] [PATCH 54/57] spp_vf: support new command x-fn-spp
2017-12-28 4:56 ` [spp] [PATCH 55/57] spp_vf: add display of status command x-fn-spp
2017-12-28 4:56 ` [spp] [PATCH 56/57] spp_vf: fix " x-fn-spp
2017-12-28 4:56 ` [spp] [PATCH 57/57] spp_vf: fix l2 multicast packet forwarding x-fn-spp
2018-01-15 11:04 ` [spp] Proposal - spp_vf(SR-IOV like feature) addition to SPP Ferruh Yigit
2018-01-16 5:16 ` [spp] [PATCH 01/30] doc: add setup guide x-fn-spp
2018-01-19 0:52 ` Yasufumi Ogawa
2018-01-22 14:37 ` Ferruh Yigit
2018-01-23 0:25 ` Yasufumi Ogawa
2018-01-16 5:16 ` [spp] [PATCH 02/30] doc: add how_to_use.md x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 03/30] doc: add config_manual.md x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 04/30] doc: add spp_vf.md x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 05/30] doc: revise spp_vf.md x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 06/30] doc: add config section x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 07/30] doc: update jp setup manual x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 08/30] doc: modify figure in spp_vf_overview x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 09/30] doc: fix " x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 10/30] doc: fix figure in overview x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 11/30] doc: add sample usage x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 12/30] doc: revice path descs x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 13/30] doc: add network configuration diagram x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 14/30] doc: update user account x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 15/30] doc: update descriptions for todo x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 16/30] doc: add description for explanation section x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 17/30] doc: add spp_sample_usage_svg in docs/spp_vf/ x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 18/30] doc: add explanation for terminating spp app x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 19/30] doc: add explanations on options of spp x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 20/30] doc: update description for the latest spp version x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 21/30] doc: update description on dpdk version x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 22/30] doc: fix vm setup procedure for network config x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 23/30] doc: update jansson installation procedure x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 24/30] doc: fix required network configuration x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 25/30] doc: add how to use vhost-user support x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 26/30] doc: add references to hugepages and isolcpus x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 27/30] doc: remove description on classifier_table x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 28/30] doc: fix typos and erros in texts x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 29/30] doc: update sample config section x-fn-spp
2018-01-16 5:16 ` [spp] [PATCH 30/30] doc: align figure title position x-fn-spp
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=201712280456.vBS4u7dD011092@imss03.silk.ntt-tx.co.jp \
--to=x-fn-spp@sl.ntt-tx.co.jp \
--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).