From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 119CEA0487 for ; Mon, 1 Jul 2019 06:12:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0A4A73195; Mon, 1 Jul 2019 06:12:04 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id BF991325F for ; Mon, 1 Jul 2019 06:12:02 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id p184so5857711pfp.7 for ; Sun, 30 Jun 2019 21:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=Z80rPL6jFFDU1uOLRWhVP+dDA49sN0DXhzf0uKkoyuI=; b=VPP3HjPxNRIN74LLMxC5tncJGjY9Byoylt9mr1wAqx3jrZsZdToeggwVtjOUH9dqU1 GN3tBLoBw7Qmgv2YwfhfN1fjja7CfW7ilKANOkjjcq05gouOC9J327vJq/bPkDsF2y61 /Z8R7hV0wfnhWb0LJLA62fD3lOW+lYC9tzs5sVSLxX/N+DMvFQ72x3pc+qaiq96S8hCU YV06u5GYSjXwLKesJ4AW9YxgIXwccsNZ6APCzFNMLiwqMHjr3RAD7gucIZ5Jzs/R9guk o137eQ4TU1Yik3xbHEaj6tg3vBk5K2HStR+g5roRc3f695QZaIfnjzPwL+S92vLrZica YMoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Z80rPL6jFFDU1uOLRWhVP+dDA49sN0DXhzf0uKkoyuI=; b=VipY9V1lOpEhDGTwdXjOEIz4+41GeFhERMXW+ZvBvRNIZ5MjJwbI2RyAtyONZojPtJ tTHtmAmSb2jQpC6wcm5y4Pc/UgaMZBpupAeZAtVL4alXq8SibVtar4iyTagvX7jna89+ 0pA8oCjqGsXs1HzxY1CJBlzCMk6+2JOBbMjZldhHTn1tcdFWxNFXpedVHilzZuAW8Ww+ lyAgaTo7r9abcfv1QqFc6iM2zRQyK+ErCn7XdyVWF3bTvZayY1y7aDhP9AXNMV1NgD/D /1lHnY69efqdhbZCASjhXsIGmL+eV/2Zaf9i6nR0uq4ghG80CF8Fjl1gJoSJ0njI4Xp7 XEEA== X-Gm-Message-State: APjAAAXd4uYmBOOmQhfYiqMx/qwl0CQ62O+gqUXp249Y3IWG0n81call NuvEddFrUHeUQ2XdlTDtRqYWx0n7 X-Google-Smtp-Source: APXvYqwdv9e3kVZFOP6gNVaSOKKxj38//+VFaOwS2mVxKvQuMLnmF9JoEfj2TWbo5JbeKz7hpb9MVw== X-Received: by 2002:a65:524b:: with SMTP id q11mr21831574pgp.384.1561954321752; Sun, 30 Jun 2019 21:12:01 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id 131sm19015550pfx.57.2019.06.30.21.12.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Jun 2019 21:12:01 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Mon, 1 Jul 2019 13:11:55 +0900 Message-Id: <20190701041156.34004-2-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190701041156.34004-1-yasufum.o@gmail.com> References: <20190701041156.34004-1-yasufum.o@gmail.com> Subject: [spp] [PATCH 1/2] shared/sec: refactor public funcs of capability X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa This update is to rename public functions `port_capability.c` and `port_capability.h` for refactoring. It also includes revising variables, structures or comments of them. Signed-off-by: Yasufumi Ogawa --- src/mirror/mir_cmd_runner.c | 2 +- src/mirror/spp_mirror.c | 4 +- src/pcap/spp_pcap.c | 2 +- .../spp_worker_th/cmd_res_formatter.c | 2 +- .../secondary/spp_worker_th/port_capability.c | 88 +++++++++++-------- .../secondary/spp_worker_th/port_capability.h | 43 ++++----- src/vf/classifier_mac.c | 3 +- src/vf/forwarder.c | 3 +- src/vf/spp_vf.c | 2 +- src/vf/vf_cmd_runner.c | 2 +- 10 files changed, 82 insertions(+), 69 deletions(-) diff --git a/src/mirror/mir_cmd_runner.c b/src/mirror/mir_cmd_runner.c index 7c9a240..3f90e9a 100644 --- a/src/mirror/mir_cmd_runner.c +++ b/src/mirror/mir_cmd_runner.c @@ -389,7 +389,7 @@ update_comp_info(struct sppwk_comp_info *p_comp_info, int *p_change_comp) continue; comp_info = (p_comp_info + cnt); - spp_port_ability_update(comp_info); + sppwk_update_port_dir(comp_info); ret = update_mirror(comp_info); RTE_LOG(DEBUG, MIR_CMD_RUNNER, "Update mirror.\n"); diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c index 4c2b90c..37327c7 100644 --- a/src/mirror/spp_mirror.c +++ b/src/mirror/spp_mirror.c @@ -288,7 +288,7 @@ change_mirror_index(int id) struct mirror_info *info = &g_mirror_info[id]; if (info->ref_index == info->upd_index) { /* Change reference index of port ability. */ - spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_REF, 0, 0); + sppwk_swap_two_sides(SPPWK_SWAP_REF, 0, 0); info->ref_index = (info->upd_index+1) % TWO_SIDES; } } @@ -521,7 +521,7 @@ main(int argc, char *argv[]) break; mirror_proc_init(); - spp_port_ability_init(); + sppwk_port_capability_init(); /* Setup connection for accepting commands from controller */ get_spp_ctl_ip(ctl_ip); diff --git a/src/pcap/spp_pcap.c b/src/pcap/spp_pcap.c index e32c360..bcce13f 100644 --- a/src/pcap/spp_pcap.c +++ b/src/pcap/spp_pcap.c @@ -946,7 +946,7 @@ main(int argc, char *argv[]) if (unlikely(ret_mng != 0)) break; - spp_port_ability_init(); + sppwk_port_capability_init(); /* Setup connection for accepting commands from controller */ get_spp_ctl_ip(ctl_ip); diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c index 2cc7d42..1485533 100644 --- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c +++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c @@ -156,7 +156,7 @@ append_vlan_block(const char *name, char **output, return SPP_RET_NG; } - spp_port_ability_get_info(port_id, dir, &port_attrs); + sppwk_get_port_attrs(&port_attrs, port_id, dir); for (i = 0; i < PORT_ABL_MAX; i++) { switch (port_attrs[i].ops) { case SPPWK_PORT_OPS_ADD_VLAN: diff --git a/src/shared/secondary/spp_worker_th/port_capability.c b/src/shared/secondary/spp_worker_th/port_capability.c index ce498fd..30c6e95 100644 --- a/src/shared/secondary/spp_worker_th/port_capability.c +++ b/src/shared/secondary/spp_worker_th/port_capability.c @@ -12,20 +12,35 @@ #include "shared/secondary/return_codes.h" #include "ringlatencystats.h" -/* Port ability management information */ -struct port_abl_info { - volatile int ref_index; /* Index to reference area. */ - volatile int upd_index; /* Index to update area. */ +/** + * TODO(yasufum) This `port capability` is intended to be used mainly for VLAN + * features. However, other features, such as two sides structure of + * management info or port direction, are also included this capability. + * For the reason, SPP worker processes other spp_vf should include the + * capability even if it is not using VLAN. It is a bad design because of + * tightly coupled for dependency and it is so confusing. + * + * This problem should be fixed in a future update. + */ + +/* Port capability management information used as a member of port_mng_info. */ +struct port_capabl_mng_info { + /* TODO(yasufum) rename ref_index and upd_index because flag. */ + /* TODO(yasufum) consider to not use two flags for (0,1) and (1,0). */ + volatile int ref_index; /* Flag to indicate using reference side. */ + volatile int upd_index; /* Flag to indicate using update side. */ + + /* A set of attrs including sppwk_port_capability. */ + /* TODO(yasufum) confirm why using PORT_ABL_MAX. */ struct sppwk_port_attrs port_attrs[TWO_SIDES][PORT_ABL_MAX]; - /* Port attributes for spp_vf. */ }; /* Port ability port information */ struct port_mng_info { enum port_type iface_type; /* Interface type (phy, vhost or so). */ int iface_no; /* Interface number. */ - struct port_abl_info rx; /* Mng data of port ability for RX. */ - struct port_abl_info tx; /* Mng data of port ability for Tx. */ + struct port_capabl_mng_info rx; /* Mng data of capability for RX. */ + struct port_capabl_mng_info tx; /* Mng data of capability for Tx. */ }; /* Information for VLAN tag management. */ @@ -34,9 +49,9 @@ struct port_mng_info g_port_mng_info[RTE_MAX_ETHPORTS]; /* TPID of VLAN. */ static uint16_t g_vlan_tpid; -/* Initialize port ability. */ +/* Initialize g_port_mng_info, and set ref side to 0 and update side to 1. */ void -spp_port_ability_init(void) +sppwk_port_capability_init(void) { int cnt = 0; g_vlan_tpid = rte_cpu_to_be_16(ETHER_TYPE_VLAN); @@ -49,13 +64,12 @@ spp_port_ability_init(void) } } -/* Get information of port ability. */ +/* Get port attributes of given ID and direction from g_port_mng_info. */ void -spp_port_ability_get_info( - int port_id, enum sppwk_port_dir dir, - struct sppwk_port_attrs **info) +sppwk_get_port_attrs(struct sppwk_port_attrs **p_attrs, + int port_id, enum sppwk_port_dir dir) { - struct port_abl_info *mng = NULL; + struct port_capabl_mng_info *mng = NULL; switch (dir) { case SPPWK_PORT_DIR_RX: @@ -68,7 +82,8 @@ spp_port_ability_get_info( /* Not used. */ break; } - *info = mng->port_attrs[mng->ref_index]; + + *p_attrs = mng->port_attrs[mng->ref_index]; } /* Calculation and Setting of FCS. */ @@ -190,20 +205,21 @@ del_vlantag_all_packets( return cnt; } -/* Change index of management information. */ +/* Swap ref side and update side. */ +/* TODO(yasufum) add desc for this function. */ void -spp_port_ability_change_index( - enum port_ability_chg_index_type type, +sppwk_swap_two_sides( + enum sppwk_swap_type swap_type, int port_id, enum sppwk_port_dir dir) { int cnt; static int num_rx; - static int rx_list[RTE_MAX_ETHPORTS]; static int num_tx; + static int rx_list[RTE_MAX_ETHPORTS]; static int tx_list[RTE_MAX_ETHPORTS]; - struct port_abl_info *mng = NULL; + struct port_capabl_mng_info *mng = NULL; - if (type == PORT_ABILITY_CHG_INDEX_UPD) { + if (swap_type == SPPWK_SWAP_UPD) { switch (dir) { case SPPWK_PORT_DIR_RX: mng = &g_port_mng_info[port_id].rx; @@ -227,14 +243,12 @@ spp_port_ability_change_index( mng->ref_index = (mng->upd_index+1) % TWO_SIDES; rx_list[cnt] = 0; } + for (cnt = 0; cnt < num_tx; cnt++) { mng = &g_port_mng_info[tx_list[cnt]].tx; mng->ref_index = (mng->upd_index+1) % TWO_SIDES; tx_list[cnt] = 0; } - - num_rx = 0; - num_tx = 0; } /* Set ability data of port ability. */ @@ -245,7 +259,7 @@ port_ability_set_ability(struct sppwk_port_info *port, int in_cnt, out_cnt = 0; int port_id = port->ethdev_port_id; struct port_mng_info *port_mng = &g_port_mng_info[port_id]; - struct port_abl_info *mng = NULL; + struct port_capabl_mng_info *mng = NULL; struct sppwk_port_attrs *port_attrs_in = port->port_attrs; struct sppwk_port_attrs *port_attrs_out = NULL; struct sppwk_vlan_tag *tag = NULL; @@ -290,24 +304,24 @@ port_ability_set_ability(struct sppwk_port_info *port, out_cnt++; } - spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_UPD, - port_id, dir); + sppwk_swap_two_sides(SPPWK_SWAP_UPD, port_id, dir); } -/* Update port capability. */ +/* Update port direction of given component. */ void -spp_port_ability_update(const struct sppwk_comp_info *component) +sppwk_update_port_dir(const struct sppwk_comp_info *comp) { int cnt; - struct sppwk_port_info *port = NULL; - for (cnt = 0; cnt < component->nof_rx; cnt++) { - port = component->rx_ports[cnt]; - port_ability_set_ability(port, SPPWK_PORT_DIR_RX); + struct sppwk_port_info *port_info = NULL; + + for (cnt = 0; cnt < comp->nof_rx; cnt++) { + port_info = comp->rx_ports[cnt]; + port_ability_set_ability(port_info, SPPWK_PORT_DIR_RX); } - for (cnt = 0; cnt < component->nof_tx; cnt++) { - port = component->tx_ports[cnt]; - port_ability_set_ability(port, SPPWK_PORT_DIR_TX); + for (cnt = 0; cnt < comp->nof_tx; cnt++) { + port_info = comp->tx_ports[cnt]; + port_ability_set_ability(port_info, SPPWK_PORT_DIR_TX); } } @@ -334,7 +348,7 @@ port_ability_each_operation(uint16_t port_id, int ok_pkts = nb_pkts; struct sppwk_port_attrs *port_attrs = NULL; - spp_port_ability_get_info(port_id, dir, &port_attrs); + sppwk_get_port_attrs(&port_attrs, port_id, dir); if (unlikely(port_attrs[0].ops == SPPWK_PORT_OPS_NONE)) return nb_pkts; diff --git a/src/shared/secondary/spp_worker_th/port_capability.h b/src/shared/secondary/spp_worker_th/port_capability.h index 5d2a38a..0593f10 100644 --- a/src/shared/secondary/spp_worker_th/port_capability.h +++ b/src/shared/secondary/spp_worker_th/port_capability.h @@ -17,45 +17,46 @@ /** Calculate TCI of VLAN tag. */ #define SPP_VLANTAG_CALC_TCI(id, pcp) (((pcp & 0x07) << 13) | (id & 0x0fff)) -/** Type for changing index. */ -enum port_ability_chg_index_type { - PORT_ABILITY_CHG_INDEX_REF, /** To change index to reference area. */ - PORT_ABILITY_CHG_INDEX_UPD, /** To change index to update area. */ +/** Type for swaping sides . */ +enum sppwk_swap_type { + SPPWK_SWAP_REF, /** Swap to reference area. */ + SPPWK_SWAP_UPD, /** Swap to update area. */ }; -/** Initialize port ability. */ -void spp_port_ability_init(void); +/** + * Initialize global variable g_port_mng_info, and set ref side to 0 and + * update side to 1. + */ +void sppwk_port_capability_init(void); /** - * Get information of port ability. + * Get port attributes of given ID and direction from global g_port_mng_info. * - * @param port_id Etherdev ID. - * @param rxtx RX/TX ID of port_id. - * @param info Port ability information. + * @param[in,out] p_attrs Port attributes. + * @param[in] port_id Etherdev ID. + * @param[in] dir Direction of teh port of sppwk_port_dir. */ -void spp_port_ability_get_info( - int port_id, enum sppwk_port_dir dir, - struct sppwk_port_attrs **info); +void sppwk_get_port_attrs( + struct sppwk_port_attrs **p_attrs, + int port_id, enum sppwk_port_dir dir); /** - * Change index of management information. + * Swap ref side and update side. * * @param port_id Etherdev ID. * @param rxtx RX/TX ID of port_id. * @param type Type for changing index. */ -void spp_port_ability_change_index( - enum port_ability_chg_index_type type, +void sppwk_swap_two_sides( + enum sppwk_swap_type swap_type, int port_id, enum sppwk_port_dir dir); /** - * Update port capability. + * Update port direction of given component. * - * @param component_info - * The pointer to struct sppwk_comp_info.@n - * The data for updating the internal data of port ability. + * @param comp Pointer to sppwk_comp_info. */ -void spp_port_ability_update(const struct sppwk_comp_info *component); +void sppwk_update_port_dir(const struct sppwk_comp_info *comp); /** * Wrapper function for rte_eth_rx_burst() with ring latency feature. diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c index 6850962..e41c65a 100644 --- a/src/vf/classifier_mac.c +++ b/src/vf/classifier_mac.c @@ -679,8 +679,7 @@ change_classifier_index(struct management_info *mng_info, int id) if (unlikely(mng_info->ref_index == mng_info->upd_index)) { /* Change reference index of port ability. */ - spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_REF, - 0, 0); + sppwk_swap_two_sides(SPPWK_SWAP_REF, 0, 0); /* Transmit all packets for switching the using data. */ transmit_all_packet(mng_info->cmp_infos + mng_info->ref_index); diff --git a/src/vf/forwarder.c b/src/vf/forwarder.c index 77afc4e..cd28a58 100644 --- a/src/vf/forwarder.c +++ b/src/vf/forwarder.c @@ -170,8 +170,7 @@ change_forward_index(int id) struct forward_info *info = &g_forward_info[id]; if (info->ref_index == info->upd_index) { /* Change reference index of port ability. */ - spp_port_ability_change_index( - PORT_ABILITY_CHG_INDEX_REF, 0, 0); + sppwk_swap_two_sides(SPPWK_SWAP_REF, 0, 0); info->ref_index = (info->upd_index+1) % TWO_SIDES; } diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c index 504ee26..dbd47bf 100644 --- a/src/vf/spp_vf.c +++ b/src/vf/spp_vf.c @@ -248,7 +248,7 @@ main(int argc, char *argv[]) break; init_forwarder(); - spp_port_ability_init(); + sppwk_port_capability_init(); /* Setup connection for accepting commands from controller */ get_spp_ctl_ip(ctl_ip); diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c index 5246af7..520398b 100644 --- a/src/vf/vf_cmd_runner.c +++ b/src/vf/vf_cmd_runner.c @@ -529,7 +529,7 @@ update_comp_info(struct sppwk_comp_info *p_comp_info, int *p_change_comp) continue; comp_info = (p_comp_info + cnt); - spp_port_ability_update(comp_info); + sppwk_update_port_dir(comp_info); if (comp_info->wk_type == SPPWK_TYPE_CLS) { ret = update_classifier(comp_info); -- 2.17.1