From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 2/2] shared/sec: refactor port capability funcs
Date: Mon, 1 Jul 2019 13:11:56 +0900 [thread overview]
Message-ID: <20190701041156.34004-3-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190701041156.34004-1-yasufum.o@gmail.com>
From: Yasufumi Ogawa <yasufum.o@gmail.com>
This update is to refactor functions for port capability defined in
`port_capability.c`. All of incorrect or ambiguous term usages are
fixed.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
.../secondary/spp_worker_th/port_capability.c | 57 +++++++++----------
1 file changed, 28 insertions(+), 29 deletions(-)
diff --git a/src/shared/secondary/spp_worker_th/port_capability.c b/src/shared/secondary/spp_worker_th/port_capability.c
index 30c6e95..db12f0c 100644
--- a/src/shared/secondary/spp_worker_th/port_capability.c
+++ b/src/shared/secondary/spp_worker_th/port_capability.c
@@ -96,9 +96,9 @@ set_fcs_packet(struct rte_mbuf *pkt)
pkt->data_len, RTE_NET_CRC32_ETH);
}
-/* Add VLAN tag to packet. */
+/* Add VLAN tag to a packet. It is called from add_vlan_tag_all(). */
static inline int
-add_vlantag_packet(
+add_vlan_tag_one(
struct rte_mbuf *pkt,
const union sppwk_port_capability *capability)
{
@@ -135,14 +135,14 @@ add_vlantag_packet(
/* Add VLAN tag to all packets. */
static inline int
-add_vlantag_all_packets(
+add_vlan_tag_all(
struct rte_mbuf **pkts, int nb_pkts,
const union sppwk_port_capability *capability)
{
int ret = SPP_RET_OK;
int cnt = 0;
for (cnt = 0; cnt < nb_pkts; cnt++) {
- ret = add_vlantag_packet(pkts[cnt], capability);
+ ret = add_vlan_tag_one(pkts[cnt], capability);
if (unlikely(ret < 0)) {
RTE_LOG(ERR, PORT,
"Failed to add VLAN tag."
@@ -153,9 +153,9 @@ add_vlantag_all_packets(
return cnt;
}
-/* Delete VLAN tag to packet. */
+/* Delete VLAN tag from a packet. It is called from del_vlan_tag_all(). */
static inline int
-del_vlantag_packet(
+del_vlan_tag_one(
struct rte_mbuf *pkt,
const union sppwk_port_capability *cbl __attribute__ ((unused)))
{
@@ -185,16 +185,16 @@ del_vlantag_packet(
return SPP_RET_OK;
}
-/* Delete VLAN tag to all packets. */
+/* Delete VLAN tag from all packets. */
static inline int
-del_vlantag_all_packets(
+del_vlan_tag_all(
struct rte_mbuf **pkts, int nb_pkts,
const union sppwk_port_capability *capability)
{
int ret = SPP_RET_OK;
int cnt = 0;
for (cnt = 0; cnt < nb_pkts; cnt++) {
- ret = del_vlantag_packet(pkts[cnt], capability);
+ ret = del_vlan_tag_one(pkts[cnt], capability);
if (unlikely(ret < 0)) {
RTE_LOG(ERR, PORT,
"Failed to del VLAN tag."
@@ -251,9 +251,9 @@ sppwk_swap_two_sides(
}
}
-/* Set ability data of port ability. */
+/* Update port attributes of given direction. */
static void
-port_ability_set_ability(struct sppwk_port_info *port,
+update_port_attrs(struct sppwk_port_info *port,
enum sppwk_port_dir dir)
{
int in_cnt, out_cnt = 0;
@@ -316,32 +316,33 @@ sppwk_update_port_dir(const struct sppwk_comp_info *comp)
for (cnt = 0; cnt < comp->nof_rx; cnt++) {
port_info = comp->rx_ports[cnt];
- port_ability_set_ability(port_info, SPPWK_PORT_DIR_RX);
+ update_port_attrs(port_info, SPPWK_PORT_DIR_RX);
}
for (cnt = 0; cnt < comp->nof_tx; cnt++) {
port_info = comp->tx_ports[cnt];
- port_ability_set_ability(port_info, SPPWK_PORT_DIR_TX);
+ update_port_attrs(port_info, SPPWK_PORT_DIR_TX);
}
}
-/* Definition of functions that operate port abilities. */
-typedef int (*port_ability_func)(
+/**
+ * Define list of VLAN opeartion functions. It is only used in
+ * vlan_operation().
+ */
+typedef int (*vlan_f)(
struct rte_mbuf **pkts, int nb_pkts,
const union sppwk_port_capability *capability);
-/* List of functions per port ability. */
-port_ability_func port_ability_function_list[] = {
- NULL, /* None */
- add_vlantag_all_packets, /* Add VLAN tag */
- del_vlantag_all_packets, /* Del VLAN tag */
- NULL /* Termination */
+vlan_f vlan_ops[] = {
+ NULL, /* None */
+ add_vlan_tag_all, /* Add VLAN tag */
+ del_vlan_tag_all, /* Del VLAN tag */
+ NULL /* Termination */
};
-/* Each packet operation of port capability. */
+/* Add or delete VLAN tag. */
static inline int
-port_ability_each_operation(uint16_t port_id,
- struct rte_mbuf **pkts, const uint16_t nb_pkts,
+vlan_operation(uint16_t port_id, struct rte_mbuf **pkts, const uint16_t nb_pkts,
enum sppwk_port_dir dir)
{
int cnt, buf;
@@ -358,7 +359,7 @@ port_ability_each_operation(uint16_t port_id,
break;
/* Add or delete VLAN tag with operation function. */
- ok_pkts = port_ability_function_list[port_attrs[cnt].ops](
+ ok_pkts = vlan_ops[port_attrs[cnt].ops](
pkts, ok_pkts, &port_attrs->capability);
}
@@ -391,8 +392,7 @@ sppwk_eth_vlan_rx_burst(uint16_t port_id,
#endif /* SPP_RINGLATENCYSTATS_ENABLE */
/* Add or delete VLAN tag. */
- return port_ability_each_operation(port_id, rx_pkts, nb_rx,
- SPPWK_PORT_DIR_RX);
+ return vlan_operation(port_id, rx_pkts, nb_rx, SPPWK_PORT_DIR_RX);
}
@@ -406,8 +406,7 @@ sppwk_eth_vlan_tx_burst(uint16_t port_id,
uint16_t nb_tx;
/* Add or delete VLAN tag. */
- nb_tx = port_ability_each_operation(port_id, tx_pkts, nb_pkts,
- SPPWK_PORT_DIR_TX);
+ nb_tx = vlan_operation(port_id, tx_pkts, nb_pkts, SPPWK_PORT_DIR_TX);
if (unlikely(nb_tx == 0))
return SPP_RET_OK;
--
2.17.1
prev parent reply other threads:[~2019-07-01 4:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 4:11 [spp] [PATCH 0/2] Refactor port capability yasufum.o
2019-07-01 4:11 ` [spp] [PATCH 1/2] shared/sec: refactor public funcs of capability yasufum.o
2019-07-01 4:11 ` yasufum.o [this message]
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=20190701041156.34004-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).