configurable PTYPE mapping
cover configurable PTYPE mapping
The patch set create new APIs that help to change the mapping from hardware defined packet type to software defined packet type for i40e NICs.
Keep these APIs private is because currently they are only meaningful for devices that support dynamic PTYPE configuration, which may not be a general device feature.
Qi Zhang (2):
net/i40e: enable per dev PTYPE mapping table
net/i40e: configurable PTYPE mapping
drivers/net/i40e/i40e_ethdev.c | 191 ++++++++++++++++++++++++++++++++++ drivers/net/i40e/i40e_ethdev.h | 3 + drivers/net/i40e/i40e_ethdev_vf.c | 2 +- drivers/net/i40e/i40e_rxtx.c | 30 ++++-- drivers/net/i40e/i40e_rxtx.h | 5 +- drivers/net/i40e/i40e_rxtx_vec_neon.c | 8 +- drivers/net/i40e/i40e_rxtx_vec_sse.c | 14 +-- drivers/net/i40e/rte_pmd_i40e.h | 81 ++++++++++++++ 8 files changed, 315 insertions(+), 19 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/2 net/i40e: enable per dev PTYPE mapping table
The mapping from hardware defined packet type to software defined packet type is static for i40e device, the patch let each ethdev to to have their own copy of mapping table, this give the possibility that different ethdev can be set different PTYPE mapping rule which is the requirement to support following hardware's dynamic PTYPE feature.
--- drivers/net/i40e/i40e_ethdev.c | 1 + drivers/net/i40e/i40e_ethdev.h | 3 +++ drivers/net/i40e/i40e_ethdev_vf.c | 2 +- drivers/net/i40e/i40e_rxtx.c | 29 ++++++++++++++++++++++------- drivers/net/i40e/i40e_rxtx.h | 3 ++- drivers/net/i40e/i40e_rxtx_vec_neon.c | 8 +++++--- drivers/net/i40e/i40e_rxtx_vec_sse.c | 14 ++++++++------ 7 files changed, 42 insertions(+), 18 deletions(-)
drivers/net/i40e/i40e_ethdev.c +1 -0
@@ -1041,6 +1041,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)i40e_set_tx_function (dev);return 0 ; } +i40e_set_default_ptype_table (dev); pci_dev =I40E_DEV_TO_PCI (dev); intr_handle = &pci_dev->intr_handle;
drivers/net/i40e/i40e_ethdev.h +3 -0
@@ -708,6 +708,9 @@ struct i40e_adapter {struct rte_timecounter systime_tc;struct rte_timecounter rx_tstamp_tc;struct rte_timecounter tx_tstamp_tc; + +/* ptype mapping table */ + uint32_t ptype_tbl[UINT8_MAX+1] __rte_cache_min_aligned; };extern const struct rte_flow_ops i40e_flow_ops;
drivers/net/i40e/i40e_ethdev_vf.c +1 -1
@@ -1476,7 +1476,7 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)i40e_set_tx_function (eth_dev);return 0 ; } - +i40e_set_default_ptype_table (eth_dev);rte_eth_copy_pci_info (eth_dev, pci_dev); eth_dev->data->dev_flags |=RTE_ETH_DEV_DETACHABLE ;
drivers/net/i40e/i40e_rxtx.c +22 -7
@@ -458,6 +458,7 @@ i40e_rx_scan_hw_ring(struct i40e_rx_queue *rxq)int32_t s[I40E_LOOK_AHEAD ], nb_dd;int32_t i, j, nb_rx =0 ;uint64_t pkt_flags; +uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl; rxdp = &rxq->rx_ring[rxq->rx_tail]; rxep = &rxq->sw_ring[rxq->rx_tail];
@@ -506,9 +507,9 @@ i40e_rx_scan_hw_ring(struct i40e_rx_queue *rxq) pkt_flags =i40e_rxd_status_to_pkt_flags (qword1); pkt_flags |=i40e_rxd_error_to_pkt_flags (qword1); mb->packet_type = -i40e_rxd_pkt_type_mapping ((uint8_t )((qword1 & -I40E_RXD_QW1_PTYPE_MASK ) >> -I40E_RXD_QW1_PTYPE_SHIFT )); + ptype_tbl[(uint8_t )((qword1 & +I40E_RXD_QW1_PTYPE_MASK ) >> +I40E_RXD_QW1_PTYPE_SHIFT )];if (pkt_flags &PKT_RX_RSS_HASH ) mb->hash.rss =rte_le_to_cpu_32 (\ rxdp[j].wb.qword0.hi_dword.rss);
@@ -700,6 +701,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)uint16_t rx_id, nb_hold;uint64_t dma_addr;uint64_t pkt_flags; +uint32_t *ptype_tbl; nb_rx =0 ; nb_hold =0 ;
@@ -707,6 +709,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rx_id = rxq->rx_tail; rx_ring = rxq->rx_ring; sw_ring = rxq->sw_ring; + ptype_tbl = rxq->vsi->adapter->ptype_tbl;while (nb_rx < nb_pkts) { rxdp = &rx_ring[rx_id];
@@ -763,8 +766,8 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) pkt_flags =i40e_rxd_status_to_pkt_flags (qword1); pkt_flags |=i40e_rxd_error_to_pkt_flags (qword1); rxm->packet_type = -i40e_rxd_pkt_type_mapping ((uint8_t )((qword1 & -I40E_RXD_QW1_PTYPE_MASK ) >>I40E_RXD_QW1_PTYPE_SHIFT )); + ptype_tbl[(uint8_t )((qword1 & +I40E_RXD_QW1_PTYPE_MASK ) >>I40E_RXD_QW1_PTYPE_SHIFT )];if (pkt_flags &PKT_RX_RSS_HASH ) rxm->hash.rss =rte_le_to_cpu_32 (rxd.wb.qword0.hi_dword.rss);
@@ -818,6 +821,7 @@ i40e_recv_scattered_pkts(void *rx_queue,uint64_t qword1;uint64_t dma_addr;uint64_t pkt_flags; +uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;while (nb_rx < nb_pkts) { rxdp = &rx_ring[rx_id];
@@ -925,8 +929,8 @@ i40e_recv_scattered_pkts(void *rx_queue, pkt_flags =i40e_rxd_status_to_pkt_flags (qword1); pkt_flags |=i40e_rxd_error_to_pkt_flags (qword1); first_seg->packet_type = -i40e_rxd_pkt_type_mapping ((uint8_t )((qword1 & -I40E_RXD_QW1_PTYPE_MASK ) >>I40E_RXD_QW1_PTYPE_SHIFT )); + ptype_tbl[(uint8_t )((qword1 & +I40E_RXD_QW1_PTYPE_MASK ) >>I40E_RXD_QW1_PTYPE_SHIFT )];if (pkt_flags &PKT_RX_RSS_HASH ) first_seg->hash.rss =rte_le_to_cpu_32 (rxd.wb.qword0.hi_dword.rss);
@@ -2853,6 +2857,17 @@ i40e_set_tx_function(struct rte_eth_dev *dev) } } +void __attribute__((cold)) +i40e_set_default_ptype_table (struct rte_eth_dev *dev) +{ +struct i40e_adapter *ad = +I40E_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); +int i; + +for (i =0 ; i <=I40E_MAX_PKT_TYPE ; i++) + ad->ptype_tbl[i] =i40e_get_default_pkt_type (i); +} +/* Stubs needed for linkage when CONFIG_RTE_I40E_INC_VECTOR is set to 'n' */ int __attribute__((weak)) i40e_rx_vec_dev_conf_condition_check(struct rte_eth_dev __rte_unused *dev)
drivers/net/i40e/i40e_rxtx.h +2 -1
@@ -262,13 +262,14 @@ void i40e_set_rx_function(struct rte_eth_dev *dev);void i40e_set_tx_function_flag (struct rte_eth_dev *dev,struct i40e_tx_queue *txq);void i40e_set_tx_function (struct rte_eth_dev *dev); +void i40e_set_default_ptype_table (struct rte_eth_dev *dev);/* For each value it means, datasheet of hardware can tell more details * * @note: fix i40e_dev_supported_ptypes_get() if any change here. */ static inline uint32_t -i40e_rxd_pkt_type_mapping (uint8_t ptype) +i40e_get_default_pkt_type (uint8_t ptype) { static const uint32_t type_table[UINT8_MAX + 1] __rte_cache_aligned = {/* L2 types */
drivers/net/i40e/i40e_rxtx_vec_neon.c +5 -3
@@ -196,7 +196,8 @@ desc_to_olflags_v(uint64x2_t descs[4], struct rte_mbuf **rx_pkts)#define I40E_VPMD_DESC_DD_MASK 0x0001000100010001ULLstatic inline void -desc_to_ptype_v (uint64x2_t descs[4 ],struct rte_mbuf **rx_pkts) +desc_to_ptype_v (uint64x2_t descs[4 ],struct rte_mbuf **rx_pkts, +uint32_t *ptype_tbl) {int i;uint8_t ptype;
@@ -205,7 +206,7 @@ desc_to_ptype_v(uint64x2_t descs[4], struct rte_mbuf **rx_pkts)for (i =0 ; i <4 ; i++) { tmp =vreinterpretq_u8_u64 (vshrq_n_u64 (descs[i],30 )); ptype =vgetq_lane_u8 (tmp,8 ); - rx_pkts[0 ]->packet_type =i40e_rxd_pkt_type_mapping (ptype); + rx_pkts[0 ]->packet_type = ptype_tbl[ptype]; } }
@@ -225,6 +226,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,uint16_t nb_pkts_recd;int pos;uint64_t var; +uint32 *ptype_tbl = rxq->vsi->adapter->ptype_tbl;/* mask to shuffle from desc. to mbuf */ uint8x16_t shuf_msk = {
@@ -429,7 +431,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, pkt_mb2);vst1q_u8 ((void *)&rx_pkts[pos]->rx_descriptor_fields1, pkt_mb1); -desc_to_ptype_v (descs, &rx_pkts[pos]); +desc_to_ptype_v (descs, &rx_pkts[pos], ptype_tbl);/* C.4 calc avaialbe number of desc */ var =__builtin_popcountll (stat &I40E_VPMD_DESC_DD_MASK ); nb_pkts_recd += var;
drivers/net/i40e/i40e_rxtx_vec_sse.c +8 -6
@@ -218,7 +218,8 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf **rx_pkts)#define PKTLEN_SHIFT 10static inline void -desc_to_ptype_v (__m128i descs[4 ],struct rte_mbuf **rx_pkts) +desc_to_ptype_v (__m128i descs[4 ],struct rte_mbuf **rx_pkts, +uint32_t *ptype_tbl) {__m128i ptype0 =_mm_unpackhi_epi64 (descs[0 ], descs[1 ]);__m128i ptype1 =_mm_unpackhi_epi64 (descs[2 ], descs[3 ]);
@@ -226,10 +227,10 @@ desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts) ptype0 =_mm_srli_epi64 (ptype0,30 ); ptype1 =_mm_srli_epi64 (ptype1,30 ); - rx_pkts[0 ]->packet_type =i40e_rxd_pkt_type_mapping (_mm_extract_epi8 (ptype0,0 )); - rx_pkts[1 ]->packet_type =i40e_rxd_pkt_type_mapping (_mm_extract_epi8 (ptype0,8 )); - rx_pkts[2 ]->packet_type =i40e_rxd_pkt_type_mapping (_mm_extract_epi8 (ptype1,0 )); - rx_pkts[3 ]->packet_type =i40e_rxd_pkt_type_mapping (_mm_extract_epi8 (ptype1,8 )); + rx_pkts[0 ]->packet_type = ptype_tbl[_mm_extract_epi8 (ptype0,0 )]; + rx_pkts[1 ]->packet_type = ptype_tbl[_mm_extract_epi8 (ptype0,8 )]; + rx_pkts[2 ]->packet_type = ptype_tbl[_mm_extract_epi8 (ptype1,0 )]; + rx_pkts[3 ]->packet_type = ptype_tbl[_mm_extract_epi8 (ptype1,8 )]; }/*
@@ -248,6 +249,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,int pos;uint64_t var;__m128i shuf_msk; +uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl; __m128i crc_adjust = _mm_set_epi16( 0, 0, 0, /* ignore non-length fields */
@@ -441,7 +443,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, pkt_mb2);_mm_storeu_si128 ((void *)&rx_pkts[pos]->rx_descriptor_fields1, pkt_mb1); -desc_to_ptype_v (descs, &rx_pkts[pos]); +desc_to_ptype_v (descs, &rx_pkts[pos], ptype_tbl);/* C.4 calc avaialbe number of desc */ var =__builtin_popcountll (_mm_cvtsi128_si64 (staterr)); nb_pkts_recd += var;
Signature · 1 line
2.9.3
PATCH 2/2 net/i40e: configurable PTYPE mapping
In reply to Qi ZhangThe patch adds 4 APIs to support configurable
PTYPE mapping for i40e device. rte_pmd_i40e_update_ptype_mapping. rte_pmd_i40e_reset_ptype_mapping. rte_pmd_i40e_get_ptype_mapping. rte_pmd_i40e_replace_ptype_mapping.
The mapping from hardware defined packet type to software defined packet type can be updated/reset/read out with these APIs.
Also a software ptype with the most significent bit set will be regarded as a custom defined ptype (RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK) so application can use it to defined its own PTYPE naming system.
--- drivers/net/i40e/i40e_ethdev.c | 190 ++++++++++++++++++++++++++++++++++++++++ drivers/net/i40e/i40e_rxtx.c | 1 - drivers/net/i40e/i40e_rxtx.h | 2 + drivers/net/i40e/rte_pmd_i40e.h | 81 +++++++++++++++++ 4 files changed, 273 insertions(+), 1 deletion(-)
drivers/net/i40e/i40e_ethdev.c +190 -0
@@ -11213,3 +11213,193 @@ rte_pmd_i40e_reset_vf_stats(uint8_t port,return 0 ; } + +static int check_invalid_pkt_type (uint32_t pkt_type) +{ + +uint32_t l2, l3, l4, tnl, il2, il3, il4; + + l2 = pkt_type &RTE_PTYPE_L2_MASK ; + l3 = pkt_type &RTE_PTYPE_L3_MASK ; + l4 = pkt_type &RTE_PTYPE_L4_MASK ; + tnl = pkt_type &RTE_PTYPE_TUNNEL_MASK ; + il2 = pkt_type &RTE_PTYPE_INNER_L2_MASK ; + il3 = pkt_type &RTE_PTYPE_INNER_L3_MASK ; + il4 = pkt_type &RTE_PTYPE_INNER_L4_MASK ; + +if (l2 !=RTE_PTYPE_L2_ETHER && + l2 !=RTE_PTYPE_L2_ETHER_TIMESYNC && + l2 !=RTE_PTYPE_L2_ETHER_LLDP && + l2 !=RTE_PTYPE_L2_ETHER_ARP ) +return -1 ; + +if (l3 !=RTE_PTYPE_L3_IPV4_EXT_UNKNOWN && + l3 !=RTE_PTYPE_L3_IPV6_EXT_UNKNOWN ) +return -1 ; + +if (l4 !=RTE_PTYPE_L4_FRAG && + l4 !=RTE_PTYPE_L4_ICMP && + l4 !=RTE_PTYPE_L4_NONFRAG && + l4 !=RTE_PTYPE_L4_SCTP && + l4 !=RTE_PTYPE_L4_TCP && + l4 !=RTE_PTYPE_L4_UDP ) +return -1 ; + +if (tnl !=RTE_PTYPE_TUNNEL_GRENAT && + tnl !=RTE_PTYPE_TUNNEL_IP ) +return -1 ; + +if (il2 !=RTE_PTYPE_INNER_L2_ETHER && + il2 !=RTE_PTYPE_INNER_L2_ETHER_VLAN ) +return -1 ; + +if (il3 !=RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN && + il3 !=RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN ) +return -1 ; + +if (il4 !=RTE_PTYPE_INNER_L4_FRAG && + il4 !=RTE_PTYPE_INNER_L4_ICMP && + il4 !=RTE_PTYPE_INNER_L4_NONFRAG && + il4 !=RTE_PTYPE_INNER_L4_SCTP && + il4 !=RTE_PTYPE_INNER_L4_TCP && + il4 !=RTE_PTYPE_INNER_L4_UDP ) +return -1 ; + +return 0 ; +} + +static int check_invalid_ptype_mapping ( +struct rte_pmd_i40e_ptype_mapping *mapping_table, +uint16_t count) +{ +int i; + +for (i =0 ; i < count; i++) { +uint16_t ptype = mapping_table[i].hw_ptype; +uint32_t pkt_type = mapping_table[i].sw_ptype; + +if (ptype >=I40E_MAX_PKT_TYPE ) +return -1 ; + +if (pkt_type ==RTE_PTYPE_UNKNOWN ) +continue ; + +if (pkt_type &RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK ) +continue ; + +if (check_invalid_pkt_type (pkt_type)) +return -1 ; + } + +return 0 ; +} + +int rte_pmd_i40e_update_ptype_mapping ( +uint8_t port, +struct rte_pmd_i40e_ptype_mapping *mapping_items, +uint16_t count, +uint8_t exclusive) +{ +struct rte_eth_dev *dev; +struct i40e_adapter *ad; +int i; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + +if (count >I40E_MAX_PKT_TYPE ) +return -EINVAL ; + +if (check_invalid_ptype_mapping (mapping_items, count)) +return -EINVAL ; + + dev = &rte_eth_devices[port]; + ad =I40E_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); + +if (exclusive) { +for (i =0 ; i <I40E_MAX_PKT_TYPE ; i++) + ad->ptype_tbl[i] =RTE_PTYPE_UNKNOWN ; + } + +for (i =0 ; i < count; i++) + ad->ptype_tbl[mapping_items[i].hw_ptype] + = mapping_items[i].sw_ptype; + +return 0 ; +} + +int rte_pmd_i40e_reset_ptype_mapping (uint8_t port) +{ +struct rte_eth_dev *dev; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; +i40e_set_default_ptype_table (dev); + +return 0 ; +} + +int rte_pmd_i40e_get_ptype_mapping ( +uint8_t port, +struct rte_pmd_i40e_ptype_mapping *mapping_items, +uint16_t size, +uint16_t *count, +uint8_t valid_only) +{ +struct rte_eth_dev *dev; +struct i40e_adapter *ad; +int n =0 ; +uint16_t i; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; + ad =I40E_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); + +for (i =0 ; i <I40E_MAX_PKT_TYPE ; i++) { +if (n >= size) +break ; +if (valid_only && ad->ptype_tbl[i] ==RTE_PTYPE_UNKNOWN ) +continue ; + mapping_items[n].hw_ptype = i; + mapping_items[n].sw_ptype = ad->ptype_tbl[i]; + n++; + } + + *count = n; +return 0 ; +} + +int rte_pmd_i40e_replace_pkt_type (uint8_t port, +uint32_t target, +uint8_t mask, +uint32_t pkt_type) +{ +struct rte_eth_dev *dev; +struct i40e_adapter *ad; +uint16_t i; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + +if (!mask &&check_invalid_pkt_type (target)) +return -EINVAL ; + +if (check_invalid_pkt_type (pkt_type)) +return -EINVAL ; + + dev = &rte_eth_devices[port]; + ad =I40E_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); + +for (i =0 ; i <I40E_MAX_PKT_TYPE ; i++) { +if (mask) { +if ((target | ad->ptype_tbl[i]) == target && + (target & ad->ptype_tbl[i])) + ad->ptype_tbl[i] = pkt_type; + }else { +if (ad->ptype_tbl[i] == target) + ad->ptype_tbl[i] = pkt_type; + } + } + +return 0 ; +}
drivers/net/i40e/i40e_rxtx.c +0 -1
@@ -61,7 +61,6 @@#define DEFAULT_TX_RS_THRESH 32#define DEFAULT_TX_FREE_THRESH 32 -#define I40E_MAX_PKT_TYPE 256#define I40E_TX_MAX_BURST 32
drivers/net/i40e/i40e_rxtx.h +2 -0
@@ -101,6 +101,8 @@ enum i40e_header_split_mode {#define i40e_rx_desc i40e_32byte_rx_desc#endif +#define I40E_MAX_PKT_TYPE 256 +struct i40e_rx_entry {struct rte_mbuf *mbuf; };
drivers/net/i40e/rte_pmd_i40e.h +81 -0
91 lines not on this page · raw message
Signature · 1 line
2.9.3
Re: [PATCH 2/2] net/i40e: configurable PTYPE mapping
Quoted 6 lines · Qi Zhang
The patch adds 4 APIs to support configurable
PTYPE mapping for i40e device.rte_pmd_i40e_update_ptype_mapping.rte_pmd_i40e_reset_ptype_mapping.rte_pmd_i40e_get_ptype_mapping.rte_pmd_i40e_replace_ptype_mapping.
Hi Qi,
These are added as PMD specific APIs, but not used anywhere, how did you test them? Or how others can test it?
Does it make sense to add them into testpmd?
And related to API naming, what do you think about following syntax:
<name_space>_<object>_<action> ?
This helps finding APIs for same object (ptype_mapping for this case):
rte_pmd_i40e_ptype_mapping_update()rte_pmd_i40e_ptype_mapping_reset()rte_pmd_i40e_ptype_mapping_get()rte_pmd_i40e_ptype_mapping_replace()
And not directly related to this patch, but it is good idea to extract PMD specific APIs into separate file, would you mind taking that task before this patch? And add these new APIs to that new file?
Quoted 6 lines
The mapping from hardware defined packet type to software defined packet type can be updated/reset/read out with these APIs.
Also a software ptype with the most significent bit set will be regarded as a custom defined ptype (RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK) so application can use it to defined its own PTYPE naming system.
Quoted 6 lines
Signed-off-by Qi Zhang <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 190 ++++++++++++++++++++++++++++++++++++++++ drivers/net/i40e/i40e_rxtx.c | 1 - drivers/net/i40e/i40e_rxtx.h | 2 + drivers/net/i40e/rte_pmd_i40e.h | 81 +++++++++++++++++
Need to update *version.map file too, for shared library build. It is hard to catch these issues since APIs are not used.
<...>
Review
Quoted 2 lines
(quoted diff) +2
-0+ +int rte_pmd_i40e_update_ptype_mapping(
DPDK coding convention suggest having return type in separate line:
int
rte_pmd_i40e_update_ptype_mapping(...
drivers/net/i40e/i40e_ethdev.c rte_pmd_i40e_reset_vf_stats(uint8_t port, · line 11305
Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c +8
-0+uint8_t port, + struct rte_pmd_i40e_ptype_mapping *mapping_items, + uint16_t count, + uint8_t exclusive) +{ + struct rte_eth_dev *dev; +struct i40e_adapter *ad; +int i;
For PMD specific APIs, port_id needs to be verified if it is i40e port or not. There is already is_device_supported() function in i40e for this.
CC'ed Wenzhuo, he already did this a few times, and may help.
<...>
Quoted 5 lines
+/**
+ * Update hardware defined ptype to software defined packet type
+ * mapping table.
+ *
+ * @param port
Quoted 8 lines
+ * pointer to port identifier of the device.
+ * @parammapping_items
+ * the base address of the mapping items array.
+ * @param count
+ * number of mapping items.
+ * @param exclusive
+ * the flag indicate different ptype mapping update method.
+ * -(0) only overwrite refferred PTYPE mapping,
referred
Quoted 6 lines
+ * keep other PTYPEs mapping unchanged.
+ * -(!0) overwrite referred PTYPE mapping,
+ * set other PTYPEs maps toPTYPE_UNKNOWN.
+ */drivers/net/i40e/rte_pmd_i40e.h +2
-0+int rte_pmd_i40e_update_ptype_mapping( + uint8_t port,
drivers/net/i40e/rte_pmd_i40e.h int rte_pmd_i40e_get_vf_stats(uint8_t port, · line 370
Quoted 10 lines
drivers/net/i40e/rte_pmd_i40e.h +10
-0+struct rte_pmd_i40e_ptype_mapping *mapping_items, + uint16_t count, + uint8_t exclusive); + +/** +* Reset hardware defined ptype to software defined ptype +* mapping table to default. +* +* @param port +* pointer to port identifiier of the device
s/identifiier/identifier
<...>
Quoted 8 lines
drivers/net/i40e/rte_pmd_i40e.h +8
-0+/** +* Replace a specific or a group of software defined ptypes +* with a new one +* +* @param port +* pointer to port identifier of the device +* @param target +* the packet type to be replaced
drivers/net/i40e/rte_pmd_i40e.h int rte_pmd_i40e_get_vf_stats(uint8_t port, · line 414
Quoted 10 lines
drivers/net/i40e/rte_pmd_i40e.h +10
-0+* @param mask +* -(0) target represent a specific software defined ptype. +* -(!0) target is a mask to represent a group of software defined ptypes. +* @param pkt_type +* the new packet type to overwrite +*/ +int rte_pmd_i40e_replace_pkt_type (uint8_t port, +uint32_t target, +uint8_t mask, +uint32_t pkt_type);
API names does not match with one in commit log, and "pkt_type" usage is not consistent with other APIs.
Quoted 3 lines
+
#endif /* _PMD_I40E_H_ */
Re: [PATCH 2/2] net/i40e: configurable PTYPE mapping
Hi Ferruh:
Thanks all the good suggestion and help.
Quoted 16 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Monday, March 6, 2017 11:32 PM
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Helin <[email protected]>
Cc: [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] net/i40e: configurable PTYPE mappingQuoted 6 lines · Qi Zhang
The patch adds 4 APIs to support configurable PTYPE mapping for i40e device.
rte_pmd_i40e_update_ptype_mapping.rte_pmd_i40e_reset_ptype_mapping.rte_pmd_i40e_get_ptype_mapping.rte_pmd_i40e_replace_ptype_mapping.
Quoted 7 lines
Hi Qi,
These are added as PMD specific APIs, but not used anywhere, how did you test them? Or how others can test it?
Does it make sense to add them into testpmd?
Yes, I plan to add
Quoted 11 lines
And related to API naming, what do you think about following syntax:
<name_space>_<object>_<action> ?This helps finding APIs for same object (
ptype_mappingfor this case):
rte_pmd_i40e_ptype_mapping_update()rte_pmd_i40e_ptype_mapping_reset()rte_pmd_i40e_ptype_mapping_get()rte_pmd_i40e_ptype_mapping_replace()
Agree, that's good.
Quoted 6 lines
And not directly related to this patch, but it is good idea to extract PMD specific APIs into separate file, would you mind taking that task before this patch? And add these new APIs to that new file?
I like this idea, since we have many changes on this recently, I'd better discuss with other team member to decide if do the separation before merge or after the merge.
Quoted 11 lines
Quoted 6 lines
The mapping from hardware defined packet type to software defined packet type can be updated/reset/read out with these APIs. Also a software ptype with the most significent bit set will be regarded as a custom defined ptype (
RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK) so application can use it todefined its own PTYPE naming system.
Quoted 4 lines
Signed-off-by Qi Zhang <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 190
Quoted 8 lines
++++++++++++++++++++++++++++++++++++++++
Quoted 3 lines
drivers/net/i40e/i40e_rxtx.c | 1 - drivers/net/i40e/i40e_rxtx.h | 2 + drivers/net/i40e/rte_pmd_i40e.h | 81 +++++++++++++++++Need to update *version.map file too, for shared library build. It is hard to catch these issues since APIs are not used.
Will fix.
Quoted 9 lines
<...>
Review
Quoted 2 lines
(quoted diff) +2
-0+ +int rte_pmd_i40e_update_ptype_mapping(DPDK coding convention suggest having return type in separate line:
int
rte_pmd_i40e_update_ptype_mapping(...
Quoted 11 lines
drivers/net/i40e/i40e_ethdev.c rte_pmd_i40e_reset_vf_stats(uint8_t port, · line 11305
Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c +8
-0+uint8_t port, + struct rte_pmd_i40e_ptype_mapping *mapping_items, + uint16_t count, + uint8_t exclusive) +{ + struct rte_eth_dev *dev; +struct i40e_adapter *ad; +int i;For PMD specific APIs,
port_idneeds to be verified if it is i40e port or not. There is alreadyis_device_supported()function in i40e for this.
Thanks
Quoted 54 lines
CC'ed Wenzhuo, he already did this a few times, and may help.
<...>
Quoted 5 lines
+/**
+ * Update hardware defined ptype to software defined packet type
+ * mapping table.
+ *
+ * @param portQuoted 8 lines
+ * pointer to port identifier of the device.
+ * @parammapping_items
+ * the base address of the mapping items array.
+ * @param count
+ * number of mapping items.
+ * @param exclusive
+ * the flag indicate different ptype mapping update method.
+ * -(0) only overwrite refferred PTYPE mapping,referred
Quoted 6 lines
+ * keep other PTYPEs mapping unchanged.
+ * -(!0) overwrite referred PTYPE mapping,
+ * set other PTYPEs maps toPTYPE_UNKNOWN.
+ */drivers/net/i40e/rte_pmd_i40e.h +2
-0+int rte_pmd_i40e_update_ptype_mapping( + uint8_t port,drivers/net/i40e/rte_pmd_i40e.h int rte_pmd_i40e_get_vf_stats(uint8_t port, · line 370
Quoted 10 lines
drivers/net/i40e/rte_pmd_i40e.h +10
-0+struct rte_pmd_i40e_ptype_mapping *mapping_items, + uint16_t count, + uint8_t exclusive); + +/** +* Reset hardware defined ptype to software defined ptype +* mapping table to default. +* +* @param port +* pointer to port identifiier of the device s/identifiier/identifier
<...>
Quoted 11 lines
+/**
+ * Replace a specific or a group of software defined ptypes
+ * with a new one
+ *
+ * @param port
+ * pointer to port identifier of the device
+ * @param target
+ * the packet type to be replaced
+ * @param mask
+ * -(0) target represent a specific software defined ptype.
+ * -(!0) target is a mask to represent a group of software definedptypes.
Quoted 10 lines
drivers/net/i40e/rte_pmd_i40e.h int rte_pmd_i40e_get_vf_stats(uint8_t port, · line 414
Quoted 7 lines
+ * @param
pkt_type
+ * the new packet type to overwrite
+ */drivers/net/i40e/rte_pmd_i40e.h +4
-0+int rte_pmd_i40e_replace_pkt_type (uint8_t port, +uint32_t target, +uint8_t mask, +uint32_t pkt_type);API names does not match with one in commit log, and "
pkt_type" usage is not consistent with other APIs.
Will fix.
Quoted 4 lines
Quoted 4 lines
+
#endif /* _PMD_I40E_H_ */
v2 cover net/i40e: configurable PTYPE mapping
In reply to Qi ZhangThe patch set create new APIs that help to change the mapping from hardware defined packet type to software defined packet type for i40e NICs. Keep these APIs private is because currently they are only meaningful for devices that support dynamic PTYPE configuration, which may not be a general device feature.
v2:
- Add testpmd command line:
ptype mapping get <port_id> <valid_only>
ptype mapping replace <port_id> <target> <mask> <pkt_type> ptype mapping reset <port_id>
ptype mapping update <port_id> <hw_ptype> <sw_ptype>
- Rename APIs to rte_pmd_i40e_ptype_mapping_xxx
- Add missing API declaration in rte_pmd_i40e_version.map
- Add missing ptype in check_invalid_pkt_type
- Fix couple typo error
Qi Zhang (3):
net/i40e: enable per dev PTYPE mapping table
net/i40e: configurable PTYPE mapping
app/testpmd: add CL for ptype mapping configure
app/test-pmd/cmdline.c | 372 ++++++++++++++++++++++++++++++ drivers/net/i40e/i40e_ethdev.c | 230 ++++++++++++++++++ drivers/net/i40e/i40e_ethdev.h | 5 + drivers/net/i40e/i40e_ethdev_vf.c | 2 +- drivers/net/i40e/i40e_rxtx.c | 30 ++- drivers/net/i40e/i40e_rxtx.h | 3 +- drivers/net/i40e/i40e_rxtx_vec_neon.c | 8 +- drivers/net/i40e/i40e_rxtx_vec_sse.c | 14 +- drivers/net/i40e/rte_pmd_i40e.h | 81 +++++++ drivers/net/i40e/rte_pmd_i40e_version.map | 4 + 10 files changed, 730 insertions(+), 19 deletions(-)
Signature · 1 line
2.9.3
PATCH v2 1/3 net/i40e: enable per dev PTYPE mapping table
The mapping from hardware defined packet type to software defined packet type is static for i40e device, the patch let each ethdev to to have their own copy of mapping table, this give the possibility that different ethdev can be set different PTYPE mapping rule which is the requirement to support following hardware's dynamic PTYPE feature.
--- drivers/net/i40e/i40e_ethdev.c | 1 + drivers/net/i40e/i40e_ethdev.h | 5 +++++ drivers/net/i40e/i40e_ethdev_vf.c | 2 +- drivers/net/i40e/i40e_rxtx.c | 30 ++++++++++++++++++++++-------- drivers/net/i40e/i40e_rxtx.h | 3 ++- drivers/net/i40e/i40e_rxtx_vec_neon.c | 8 +++++--- drivers/net/i40e/i40e_rxtx_vec_sse.c | 14 ++++++++------ 7 files changed, 44 insertions(+), 19 deletions(-)
drivers/net/i40e/i40e_ethdev.c +1 -0
@@ -1041,6 +1041,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)i40e_set_tx_function (dev);return 0 ; } +i40e_set_default_ptype_table (dev); pci_dev =I40E_DEV_TO_PCI (dev); intr_handle = &pci_dev->intr_handle;
drivers/net/i40e/i40e_ethdev.h +5 -0
@@ -684,6 +684,8 @@ struct i40e_vf {uint64_t flags; }; +#define I40E_MAX_PKT_TYPE 256 +/* * Structure to store private data for each PF/VF instance. */
@@ -708,6 +710,9 @@ struct i40e_adapter {struct rte_timecounter systime_tc;struct rte_timecounter rx_tstamp_tc;struct rte_timecounter tx_tstamp_tc; + +/* ptype mapping table */ + uint32_t ptype_tbl[I40E_MAX_PKT_TYPE] __rte_cache_min_aligned; };extern const struct rte_flow_ops i40e_flow_ops;
drivers/net/i40e/i40e_ethdev_vf.c +1 -1
@@ -1476,7 +1476,7 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)i40e_set_tx_function (eth_dev);return 0 ; } - +i40e_set_default_ptype_table (eth_dev);rte_eth_copy_pci_info (eth_dev, pci_dev); eth_dev->data->dev_flags |=RTE_ETH_DEV_DETACHABLE ;
drivers/net/i40e/i40e_rxtx.c +22 -8
@@ -61,7 +61,6 @@#define DEFAULT_TX_RS_THRESH 32#define DEFAULT_TX_FREE_THRESH 32 -#define I40E_MAX_PKT_TYPE 256#define I40E_TX_MAX_BURST 32
@@ -458,6 +457,7 @@ i40e_rx_scan_hw_ring(struct i40e_rx_queue *rxq)int32_t s[I40E_LOOK_AHEAD ], nb_dd;int32_t i, j, nb_rx =0 ;uint64_t pkt_flags; +uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl; rxdp = &rxq->rx_ring[rxq->rx_tail]; rxep = &rxq->sw_ring[rxq->rx_tail];
@@ -506,9 +506,9 @@ i40e_rx_scan_hw_ring(struct i40e_rx_queue *rxq) pkt_flags =i40e_rxd_status_to_pkt_flags (qword1); pkt_flags |=i40e_rxd_error_to_pkt_flags (qword1); mb->packet_type = -i40e_rxd_pkt_type_mapping ((uint8_t )((qword1 & -I40E_RXD_QW1_PTYPE_MASK ) >> -I40E_RXD_QW1_PTYPE_SHIFT )); + ptype_tbl[(uint8_t )((qword1 & +I40E_RXD_QW1_PTYPE_MASK ) >> +I40E_RXD_QW1_PTYPE_SHIFT )];if (pkt_flags &PKT_RX_RSS_HASH ) mb->hash.rss =rte_le_to_cpu_32 (\ rxdp[j].wb.qword0.hi_dword.rss);
@@ -700,6 +700,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)uint16_t rx_id, nb_hold;uint64_t dma_addr;uint64_t pkt_flags; +uint32_t *ptype_tbl; nb_rx =0 ; nb_hold =0 ;
@@ -707,6 +708,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rx_id = rxq->rx_tail; rx_ring = rxq->rx_ring; sw_ring = rxq->sw_ring; + ptype_tbl = rxq->vsi->adapter->ptype_tbl;while (nb_rx < nb_pkts) { rxdp = &rx_ring[rx_id];
@@ -763,8 +765,8 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) pkt_flags =i40e_rxd_status_to_pkt_flags (qword1); pkt_flags |=i40e_rxd_error_to_pkt_flags (qword1); rxm->packet_type = -i40e_rxd_pkt_type_mapping ((uint8_t )((qword1 & -I40E_RXD_QW1_PTYPE_MASK ) >>I40E_RXD_QW1_PTYPE_SHIFT )); + ptype_tbl[(uint8_t )((qword1 & +I40E_RXD_QW1_PTYPE_MASK ) >>I40E_RXD_QW1_PTYPE_SHIFT )];if (pkt_flags &PKT_RX_RSS_HASH ) rxm->hash.rss =rte_le_to_cpu_32 (rxd.wb.qword0.hi_dword.rss);
@@ -818,6 +820,7 @@ i40e_recv_scattered_pkts(void *rx_queue,uint64_t qword1;uint64_t dma_addr;uint64_t pkt_flags; +uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;while (nb_rx < nb_pkts) { rxdp = &rx_ring[rx_id];
@@ -925,8 +928,8 @@ i40e_recv_scattered_pkts(void *rx_queue, pkt_flags =i40e_rxd_status_to_pkt_flags (qword1); pkt_flags |=i40e_rxd_error_to_pkt_flags (qword1); first_seg->packet_type = -i40e_rxd_pkt_type_mapping ((uint8_t )((qword1 & -I40E_RXD_QW1_PTYPE_MASK ) >>I40E_RXD_QW1_PTYPE_SHIFT )); + ptype_tbl[(uint8_t )((qword1 & +I40E_RXD_QW1_PTYPE_MASK ) >>I40E_RXD_QW1_PTYPE_SHIFT )];if (pkt_flags &PKT_RX_RSS_HASH ) first_seg->hash.rss =rte_le_to_cpu_32 (rxd.wb.qword0.hi_dword.rss);
@@ -2853,6 +2856,17 @@ i40e_set_tx_function(struct rte_eth_dev *dev) } } +void __attribute__((cold)) +i40e_set_default_ptype_table (struct rte_eth_dev *dev) +{ +struct i40e_adapter *ad = +I40E_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); +int i; + +for (i =0 ; i <=I40E_MAX_PKT_TYPE ; i++) + ad->ptype_tbl[i] =i40e_get_default_pkt_type (i); +} +/* Stubs needed for linkage when CONFIG_RTE_I40E_INC_VECTOR is set to 'n' */ int __attribute__((weak)) i40e_rx_vec_dev_conf_condition_check(struct rte_eth_dev __rte_unused *dev)
drivers/net/i40e/i40e_rxtx.h +2 -1
@@ -262,13 +262,14 @@ void i40e_set_rx_function(struct rte_eth_dev *dev);void i40e_set_tx_function_flag (struct rte_eth_dev *dev,struct i40e_tx_queue *txq);void i40e_set_tx_function (struct rte_eth_dev *dev); +void i40e_set_default_ptype_table (struct rte_eth_dev *dev);/* For each value it means, datasheet of hardware can tell more details * * @note: fix i40e_dev_supported_ptypes_get() if any change here. */ static inline uint32_t -i40e_rxd_pkt_type_mapping (uint8_t ptype) +i40e_get_default_pkt_type (uint8_t ptype) { static const uint32_t type_table[UINT8_MAX + 1] __rte_cache_aligned = {/* L2 types */
drivers/net/i40e/i40e_rxtx_vec_neon.c +5 -3
@@ -196,7 +196,8 @@ desc_to_olflags_v(uint64x2_t descs[4], struct rte_mbuf **rx_pkts)#define I40E_VPMD_DESC_DD_MASK 0x0001000100010001ULLstatic inline void -desc_to_ptype_v (uint64x2_t descs[4 ],struct rte_mbuf **rx_pkts) +desc_to_ptype_v (uint64x2_t descs[4 ],struct rte_mbuf **rx_pkts, +uint32_t *ptype_tbl) {int i;uint8_t ptype;
@@ -205,7 +206,7 @@ desc_to_ptype_v(uint64x2_t descs[4], struct rte_mbuf **rx_pkts)for (i =0 ; i <4 ; i++) { tmp =vreinterpretq_u8_u64 (vshrq_n_u64 (descs[i],30 )); ptype =vgetq_lane_u8 (tmp,8 ); - rx_pkts[0 ]->packet_type =i40e_rxd_pkt_type_mapping (ptype); + rx_pkts[0 ]->packet_type = ptype_tbl[ptype]; } }
@@ -225,6 +226,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,uint16_t nb_pkts_recd;int pos;uint64_t var; +uint32 *ptype_tbl = rxq->vsi->adapter->ptype_tbl;/* mask to shuffle from desc. to mbuf */ uint8x16_t shuf_msk = {
@@ -429,7 +431,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, pkt_mb2);vst1q_u8 ((void *)&rx_pkts[pos]->rx_descriptor_fields1, pkt_mb1); -desc_to_ptype_v (descs, &rx_pkts[pos]); +desc_to_ptype_v (descs, &rx_pkts[pos], ptype_tbl);/* C.4 calc avaialbe number of desc */ var =__builtin_popcountll (stat &I40E_VPMD_DESC_DD_MASK ); nb_pkts_recd += var;
drivers/net/i40e/i40e_rxtx_vec_sse.c +8 -6
@@ -218,7 +218,8 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf **rx_pkts)#define PKTLEN_SHIFT 10static inline void -desc_to_ptype_v (__m128i descs[4 ],struct rte_mbuf **rx_pkts) +desc_to_ptype_v (__m128i descs[4 ],struct rte_mbuf **rx_pkts, +uint32_t *ptype_tbl) {__m128i ptype0 =_mm_unpackhi_epi64 (descs[0 ], descs[1 ]);__m128i ptype1 =_mm_unpackhi_epi64 (descs[2 ], descs[3 ]);
@@ -226,10 +227,10 @@ desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts) ptype0 =_mm_srli_epi64 (ptype0,30 ); ptype1 =_mm_srli_epi64 (ptype1,30 ); - rx_pkts[0 ]->packet_type =i40e_rxd_pkt_type_mapping (_mm_extract_epi8 (ptype0,0 )); - rx_pkts[1 ]->packet_type =i40e_rxd_pkt_type_mapping (_mm_extract_epi8 (ptype0,8 )); - rx_pkts[2 ]->packet_type =i40e_rxd_pkt_type_mapping (_mm_extract_epi8 (ptype1,0 )); - rx_pkts[3 ]->packet_type =i40e_rxd_pkt_type_mapping (_mm_extract_epi8 (ptype1,8 )); + rx_pkts[0 ]->packet_type = ptype_tbl[_mm_extract_epi8 (ptype0,0 )]; + rx_pkts[1 ]->packet_type = ptype_tbl[_mm_extract_epi8 (ptype0,8 )]; + rx_pkts[2 ]->packet_type = ptype_tbl[_mm_extract_epi8 (ptype1,0 )]; + rx_pkts[3 ]->packet_type = ptype_tbl[_mm_extract_epi8 (ptype1,8 )]; }/*
@@ -248,6 +249,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,int pos;uint64_t var;__m128i shuf_msk; +uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl; __m128i crc_adjust = _mm_set_epi16( 0, 0, 0, /* ignore non-length fields */
@@ -441,7 +443,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, pkt_mb2);_mm_storeu_si128 ((void *)&rx_pkts[pos]->rx_descriptor_fields1, pkt_mb1); -desc_to_ptype_v (descs, &rx_pkts[pos]); +desc_to_ptype_v (descs, &rx_pkts[pos], ptype_tbl);/* C.4 calc avaialbe number of desc */ var =__builtin_popcountll (_mm_cvtsi128_si64 (staterr)); nb_pkts_recd += var;
Signature · 1 line
2.9.3
PATCH v2 2/3 net/i40e: configurable PTYPE mapping
In reply to Qi ZhangThe patch adds 4 APIs to support configurable
PTYPE mapping for i40e device. rte_pmd_i40e_ptype_mapping_get. rte_pmd_i40e_ptype_mapping_replace. rte_pmd_i40e_ptype_mapping_reset. rte_pmd_i40e_ptype_mapping_update.
The mapping from hardware defined packet type to software defined packet type can be updated/reset/read out with these APIs.
Also a software ptype with the most significent bit set will be regarded as a custom defined ptype (RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK) so application can use it to defined its own PTYPE naming system.
---
v2:
- Rename APIs to rte_pmd_i40e_ptype_mapping_xxx
- Add missing API declaration in rte_pmd_i40e_version.map
- Add missing PTYPE in check_invalid_pkt_type
- Fix couple typo error
drivers/net/i40e/i40e_ethdev.c | 229 ++++++++++++++++++++++++++++++ drivers/net/i40e/rte_pmd_i40e.h | 81 +++++++++++ drivers/net/i40e/rte_pmd_i40e_version.map | 4 + 3 files changed, 314 insertions(+)
drivers/net/i40e/i40e_ethdev.c +229 -0
@@ -11213,3 +11213,232 @@ rte_pmd_i40e_reset_vf_stats(uint8_t port,return 0 ; } + +static int check_invalid_pkt_type (uint32_t pkt_type) +{ +uint32_t l2, l3, l4, tnl, il2, il3, il4; + + l2 = pkt_type &RTE_PTYPE_L2_MASK ; + l3 = pkt_type &RTE_PTYPE_L3_MASK ; + l4 = pkt_type &RTE_PTYPE_L4_MASK ; + tnl = pkt_type &RTE_PTYPE_TUNNEL_MASK ; + il2 = pkt_type &RTE_PTYPE_INNER_L2_MASK ; + il3 = pkt_type &RTE_PTYPE_INNER_L3_MASK ; + il4 = pkt_type &RTE_PTYPE_INNER_L4_MASK ; + +if (l2 && + l2 !=RTE_PTYPE_L2_ETHER && + l2 !=RTE_PTYPE_L2_ETHER_TIMESYNC && + l2 !=RTE_PTYPE_L2_ETHER_ARP && + l2 !=RTE_PTYPE_L2_ETHER_LLDP && + l2 !=RTE_PTYPE_L2_ETHER_NSH && + l2 !=RTE_PTYPE_L2_ETHER_VLAN && + l2 !=RTE_PTYPE_L2_ETHER_QINQ ) +return -1 ; + +if (l3 && + l3 !=RTE_PTYPE_L3_IPV4 && + l3 !=RTE_PTYPE_L3_IPV4_EXT && + l3 !=RTE_PTYPE_L3_IPV6 && + l3 !=RTE_PTYPE_L3_IPV4_EXT_UNKNOWN && + l3 !=RTE_PTYPE_L3_IPV6_EXT && + l3 !=RTE_PTYPE_L3_IPV6_EXT_UNKNOWN ) +return -1 ; + +if (l4 && + l4 !=RTE_PTYPE_L4_TCP && + l4 !=RTE_PTYPE_L4_UDP && + l4 !=RTE_PTYPE_L4_FRAG && + l4 !=RTE_PTYPE_L4_SCTP && + l4 !=RTE_PTYPE_L4_ICMP && + l4 !=RTE_PTYPE_L4_NONFRAG ) +return -1 ; + +if (tnl && + tnl !=RTE_PTYPE_TUNNEL_IP && + tnl !=RTE_PTYPE_TUNNEL_GRENAT && + tnl !=RTE_PTYPE_TUNNEL_VXLAN && + tnl !=RTE_PTYPE_TUNNEL_NVGRE && + tnl !=RTE_PTYPE_TUNNEL_GENEVE && + tnl !=RTE_PTYPE_TUNNEL_GRENAT ) +return -1 ; + +if (il2 && + il2 !=RTE_PTYPE_INNER_L2_ETHER && + il2 !=RTE_PTYPE_INNER_L2_ETHER_VLAN && + il2 !=RTE_PTYPE_INNER_L2_ETHER_QINQ ) +return -1 ; + +if (il3 && + il3 !=RTE_PTYPE_INNER_L3_IPV4 && + il3 !=RTE_PTYPE_INNER_L3_IPV4_EXT && + il3 !=RTE_PTYPE_INNER_L3_IPV6 && + il3 !=RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN && + il3 !=RTE_PTYPE_INNER_L3_IPV6_EXT && + il3 !=RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN ) +return -1 ; + +if (il4 && + il4 !=RTE_PTYPE_INNER_L4_TCP && + il4 !=RTE_PTYPE_INNER_L4_UDP && + il4 !=RTE_PTYPE_INNER_L4_FRAG && + il4 !=RTE_PTYPE_INNER_L4_SCTP && + il4 !=RTE_PTYPE_INNER_L4_ICMP && + il4 !=RTE_PTYPE_INNER_L4_NONFRAG ) +return -1 ; + +return 0 ; +} + +static int check_invalid_ptype_mapping ( +struct rte_pmd_i40e_ptype_mapping *mapping_table, +uint16_t count) +{ +int i; + +for (i =0 ; i < count; i++) { +uint16_t ptype = mapping_table[i].hw_ptype; +uint32_t pkt_type = mapping_table[i].sw_ptype; + +if (ptype >=I40E_MAX_PKT_TYPE ) +return -1 ; + +if (pkt_type ==RTE_PTYPE_UNKNOWN ) +continue ; + +if (pkt_type &RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK ) +continue ; + +if (check_invalid_pkt_type (pkt_type)) +return -1 ; + } + +return 0 ; +} + +int +rte_pmd_i40e_ptype_mapping_update ( +uint8_t port, +struct rte_pmd_i40e_ptype_mapping *mapping_items, +uint16_t count, +uint8_t exclusive) +{ +struct rte_eth_dev *dev; +struct i40e_adapter *ad; +int i; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; + +if (!is_device_supported (dev, &rte_i40e_pmd)) +return -ENOTSUP ; + +if (count >I40E_MAX_PKT_TYPE ) +return -EINVAL ; + +if (check_invalid_ptype_mapping (mapping_items, count)) +return -EINVAL ; + + ad =I40E_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); + +if (exclusive) { +for (i =0 ; i <I40E_MAX_PKT_TYPE ; i++) + ad->ptype_tbl[i] =RTE_PTYPE_UNKNOWN ; + } + +for (i =0 ; i < count; i++) + ad->ptype_tbl[mapping_items[i].hw_ptype] + = mapping_items[i].sw_ptype; + +return 0 ; +} + +int rte_pmd_i40e_ptype_mapping_reset (uint8_t port) +{ +struct rte_eth_dev *dev; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; + +if (!is_device_supported (dev, &rte_i40e_pmd)) +return -ENOTSUP ; + +i40e_set_default_ptype_table (dev); + +return 0 ; +} + +int rte_pmd_i40e_ptype_mapping_get ( +uint8_t port, +struct rte_pmd_i40e_ptype_mapping *mapping_items, +uint16_t size, +uint16_t *count, +uint8_t valid_only) +{ +struct rte_eth_dev *dev; +struct i40e_adapter *ad; +int n =0 ; +uint16_t i; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; + +if (!is_device_supported (dev, &rte_i40e_pmd)) +return -ENOTSUP ; + + ad =I40E_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); + +for (i =0 ; i <I40E_MAX_PKT_TYPE ; i++) { +if (n >= size) +break ; +if (valid_only && ad->ptype_tbl[i] ==RTE_PTYPE_UNKNOWN ) +continue ; + mapping_items[n].hw_ptype = i; + mapping_items[n].sw_ptype = ad->ptype_tbl[i]; + n++; + } + + *count = n; +return 0 ; +} + +int rte_pmd_i40e_ptype_mapping_replace (uint8_t port, +uint32_t target, +uint8_t mask, +uint32_t pkt_type) +{ +struct rte_eth_dev *dev; +struct i40e_adapter *ad; +uint16_t i; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); + + dev = &rte_eth_devices[port]; + +if (!is_device_supported (dev, &rte_i40e_pmd)) +return -ENOTSUP ; + +if (!mask &&check_invalid_pkt_type (target)) +return -EINVAL ; + +if (check_invalid_pkt_type (pkt_type)) +return -EINVAL ; + + ad =I40E_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); + +for (i =0 ; i <I40E_MAX_PKT_TYPE ; i++) { +if (mask) { +if ((target | ad->ptype_tbl[i]) == target && + (target & ad->ptype_tbl[i])) + ad->ptype_tbl[i] = pkt_type; + }else { +if (ad->ptype_tbl[i] == target) + ad->ptype_tbl[i] = pkt_type; + } + } + +return 0 ; +}
drivers/net/i40e/rte_pmd_i40e.h +81 -0
91 lines not on this page · raw message
drivers/net/i40e/rte_pmd_i40e_version.map +4 -0
@@ -8,6 +8,10 @@ DPDK_17.02 { rte_pmd_i40e_get_vf_stats; rte_pmd_i40e_ping_vfs; + rte_pmd_i40e_ptype_mapping_get; + rte_pmd_i40e_ptype_mapping_replace; + rte_pmd_i40e_ptype_mapping_reset; + rte_pmd_i40e_ptype_mapping_update; rte_pmd_i40e_reset_vf_stats; rte_pmd_i40e_set_tx_loopback; rte_pmd_i40e_set_vf_broadcast;
Signature · 1 line
2.9.3
PATCH v2 3/3 app/testpmd: add CL for ptype mapping configure
In reply to Qi ZhangAdd below command line to configure ptype mapping. ptype mapping get <port_id> <valid_only>.
ptype mapping replace <port_id> <target> <mask> <pkt_type>. ptype mapping reset <port_id>.
ptype mapping update <port_id> <hw_ptype> <sw_ptype>.
--- app/test-pmd/cmdline.c | 372 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 372 insertions(+)
app/test-pmd/cmdline.c +372 -0
@@ -575,6 +575,18 @@ static void cmd_help_long_parsed(void *parsed_result,"E-tag set filter del e-tag-id (value) port (port_id)\n" " Delete an E-tag forwarding filter on a port\n\n" +"ptype mapping get (port_id) (valid_only)\n" +" Get ptype mapping on a port\n\n" + +"ptype mapping replace (port_id) (target) (mask) (pky_type)\n" +" Replace target with the pkt_type in ptype mapping\n\n" + +"ptype mapping reset (port_id)\n" +" Reset ptype mapping on a port\n\n" + +"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" +" Update a ptype mapping item on a port\n\n" + ,list_pkt_forwarding_modes () ); }
@@ -12395,6 +12407,362 @@ cmdline_parse_inst_t cmd_set_vf_vlan_tag = { }, }; +/* ptype mapping get */ + +/* Common result structure for ptype mapping get */ +struct cmd_ptype_mapping_get_result { +cmdline_fixed_string_t ptype; +cmdline_fixed_string_t mapping; +cmdline_fixed_string_t get; +uint8_t port_id; +uint8_t valid_only; +}; + +/* Common CLI fields for ptype mapping get */ +cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_get_result, + ptype,"ptype" ); +cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_get_result, + mapping,"mapping" ); +cmdline_parse_token_string_t cmd_ptype_mapping_get_get = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_get_result, + get,"get" ); +cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = +TOKEN_NUM_INITIALIZER + (struct cmd_ptype_mapping_get_result, + port_id,UINT8 ); +cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = +TOKEN_NUM_INITIALIZER + (struct cmd_ptype_mapping_get_result, + valid_only,UINT8 ); + +static void +cmd_ptype_mapping_get_parsed ( +void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_ptype_mapping_get_result *res = parsed_result; +#ifdef RTE_LIBRTE_I40E_PMD +int ret = -ENOTSUP ; +int max_ptype_num =256 ; +struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; +uint16_t count; +int i; +#endif + +if (port_id_is_invalid (res->port_id,ENABLED_WARN )) +return ; + +#ifdef RTE_LIBRTE_I40E_PMD + ret =rte_pmd_i40e_ptype_mapping_get (res->port_id, + mapping, + max_ptype_num, + &count, + res->valid_only); +#endif + +switch (ret) { +case 0 : +break ; +case -ENODEV : +printf ("invalid port_id %d\n" , res->port_id); +break ; +case -ENOTSUP : +printf ("function not implemented\n" ); +break ; +default : +printf ("programming error: (%s)\n" ,strerror (-ret)); + } + +#ifdef RTE_LIBRTE_I40E_PMD +if (!ret) { +for (i =0 ; i < count; i++) +printf ("%3d\t0x%08x\n" , + mapping[i].hw_ptype, mapping[i].sw_ptype); + } +#endif +} + +cmdline_parse_inst_t cmd_ptype_mapping_get = { + .f = cmd_ptype_mapping_get_parsed, + .data =NULL , + .help_str ="ptype mapping get <port_id> <valid_only>" , + .tokens = { + (void *)&cmd_ptype_mapping_get_ptype, + (void *)&cmd_ptype_mapping_get_mapping, + (void *)&cmd_ptype_mapping_get_get, + (void *)&cmd_ptype_mapping_get_port_id, + (void *)&cmd_ptype_mapping_get_valid_only, +NULL , + }, +}; + +/* ptype mapping replace */ + +/* Common result structure for ptype mapping replace */ +struct cmd_ptype_mapping_replace_result { +cmdline_fixed_string_t ptype; +cmdline_fixed_string_t mapping; +cmdline_fixed_string_t replace; +uint8_t port_id; +uint32_t target; +uint8_t mask; +uint32_t pkt_type; +}; + +/* Common CLI fields for ptype mapping replace */ +cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_replace_result, + ptype,"ptype" ); +cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_replace_result, + mapping,"mapping" ); +cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_replace_result, + replace,"replace" ); +cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = +TOKEN_NUM_INITIALIZER + (struct cmd_ptype_mapping_replace_result, + port_id,UINT8 ); +cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = +TOKEN_NUM_INITIALIZER + (struct cmd_ptype_mapping_replace_result, + target,UINT32 ); +cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = +TOKEN_NUM_INITIALIZER + (struct cmd_ptype_mapping_replace_result, + mask,UINT8 ); +cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = +TOKEN_NUM_INITIALIZER + (struct cmd_ptype_mapping_replace_result, + pkt_type,UINT32 ); + +static void +cmd_ptype_mapping_replace_parsed ( +void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_ptype_mapping_replace_result *res = parsed_result; +int ret = -ENOTSUP ; + +if (port_id_is_invalid (res->port_id,ENABLED_WARN )) +return ; + +#ifdef RTE_LIBRTE_I40E_PMD + ret =rte_pmd_i40e_ptype_mapping_replace (res->port_id, + res->target, + res->mask, + res->pkt_type); +#endif + +switch (ret) { +case 0 : +break ; +case -EINVAL : +printf ("invalid ptype 0x%8x or 0x%8x\n" , + res->target, res->pkt_type); +break ; +case -ENODEV : +printf ("invalid port_id %d\n" , res->port_id); +break ; +case -ENOTSUP : +printf ("function not implemented\n" ); +break ; +default : +printf ("programming error: (%s)\n" ,strerror (-ret)); + } +} + +cmdline_parse_inst_t cmd_ptype_mapping_replace = { + .f = cmd_ptype_mapping_replace_parsed, + .data =NULL , + .help_str = +"ptype mapping replace <port_id> <target> <mask> <pkt_type>" , + .tokens = { + (void *)&cmd_ptype_mapping_replace_ptype, + (void *)&cmd_ptype_mapping_replace_mapping, + (void *)&cmd_ptype_mapping_replace_replace, + (void *)&cmd_ptype_mapping_replace_port_id, + (void *)&cmd_ptype_mapping_replace_target, + (void *)&cmd_ptype_mapping_replace_mask, + (void *)&cmd_ptype_mapping_replace_pkt_type, +NULL , + }, +}; + +/* ptype mapping reset */ + +/* Common result structure for ptype mapping reset */ +struct cmd_ptype_mapping_reset_result { +cmdline_fixed_string_t ptype; +cmdline_fixed_string_t mapping; +cmdline_fixed_string_t reset; +uint8_t port_id; +}; + +/* Common CLI fields for ptype mapping reset*/ +cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_reset_result, + ptype,"ptype" ); +cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_reset_result, + mapping,"mapping" ); +cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_reset_result, + reset,"reset" ); +cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = +TOKEN_NUM_INITIALIZER + (struct cmd_ptype_mapping_reset_result, + port_id,UINT8 ); + +static void +cmd_ptype_mapping_reset_parsed ( +void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_ptype_mapping_reset_result *res = parsed_result; +int ret = -ENOTSUP ; + +if (port_id_is_invalid (res->port_id,ENABLED_WARN )) +return ; + +#ifdef RTE_LIBRTE_I40E_PMD + ret =rte_pmd_i40e_ptype_mapping_reset (res->port_id); +#endif + +switch (ret) { +case 0 : +break ; +case -ENODEV : +printf ("invalid port_id %d\n" , res->port_id); +break ; +case -ENOTSUP : +printf ("function not implemented\n" ); +break ; +default : +printf ("programming error: (%s)\n" ,strerror (-ret)); + } +} + +cmdline_parse_inst_t cmd_ptype_mapping_reset = { + .f = cmd_ptype_mapping_reset_parsed, + .data =NULL , + .help_str ="ptype mapping reset <port_id>" , + .tokens = { + (void *)&cmd_ptype_mapping_reset_ptype, + (void *)&cmd_ptype_mapping_reset_mapping, + (void *)&cmd_ptype_mapping_reset_reset, + (void *)&cmd_ptype_mapping_reset_port_id, +NULL , + }, +}; + +/* ptype mapping update */ + +/* Common result structure for ptype mapping update */ +struct cmd_ptype_mapping_update_result { +cmdline_fixed_string_t ptype; +cmdline_fixed_string_t mapping; +cmdline_fixed_string_t reset; +uint8_t port_id; +uint8_t hw_ptype; +uint32_t sw_ptype; +}; + +/* Common CLI fields for ptype mapping update*/ +cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_update_result, + ptype,"ptype" ); +cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_update_result, + mapping,"mapping" ); +cmdline_parse_token_string_t cmd_ptype_mapping_update_update = +TOKEN_STRING_INITIALIZER + (struct cmd_ptype_mapping_update_result, + reset,"update" ); +cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = +TOKEN_NUM_INITIALIZER + (struct cmd_ptype_mapping_update_result, + port_id,UINT8 ); +cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = +TOKEN_NUM_INITIALIZER + (struct cmd_ptype_mapping_update_result, + hw_ptype,UINT8 ); +cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = +TOKEN_NUM_INITIALIZER + (struct cmd_ptype_mapping_update_result, + sw_ptype,UINT32 ); + +static void +cmd_ptype_mapping_update_parsed ( +void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_ptype_mapping_update_result *res = parsed_result; +int ret = -ENOTSUP ; +#ifdef RTE_LIBRTE_I40E_PMD +struct rte_pmd_i40e_ptype_mapping mapping; +#endif +if (port_id_is_invalid (res->port_id,ENABLED_WARN )) +return ; + +#ifdef RTE_LIBRTE_I40E_PMD + mapping.hw_ptype = res->hw_ptype; + mapping.sw_ptype = res->sw_ptype; + ret =rte_pmd_i40e_ptype_mapping_update (res->port_id, + &mapping, +1 , +0 ); +#endif + +switch (ret) { +case 0 : +break ; +case -EINVAL : +printf ("invalid ptype 0x%8x\n" , res->sw_ptype); +break ; +case -ENODEV : +printf ("invalid port_id %d\n" , res->port_id); +break ; +case -ENOTSUP : +printf ("function not implemented\n" ); +break ; +default : +printf ("programming error: (%s)\n" ,strerror (-ret)); + } +} + +cmdline_parse_inst_t cmd_ptype_mapping_update = { + .f = cmd_ptype_mapping_update_parsed, + .data =NULL , + .help_str ="ptype mapping update <port_id> <hw_ptype> <sw_ptype>" , + .tokens = { + (void *)&cmd_ptype_mapping_update_ptype, + (void *)&cmd_ptype_mapping_update_mapping, + (void *)&cmd_ptype_mapping_update_update, + (void *)&cmd_ptype_mapping_update_port_id, + (void *)&cmd_ptype_mapping_update_hw_ptype, + (void *)&cmd_ptype_mapping_update_sw_ptype, +NULL , + }, +}; +/* ******************************************************************************** */ /* list of instructions */
@@ -12570,6 +12938,10 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, + (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, + (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, + (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, + (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, NULL, };
Signature · 1 line
2.9.3
Re: [PATCH v2 3/3] app/testpmd: add CL for ptype mapping configure
Quoted 21 lines · Qi Zhang
Add below command line to configure ptype mapping. ptype mapping get <
port_id> <valid_only>.
ptype mapping replace <port_id> <target> <mask> <pkt_type>. ptype mapping reset <port_id>.
ptype mapping update <port_id> <hw_ptype> <sw_ptype>.Signed-off-by Qi Zhang <[email protected]>--- app/test-pmd/cmdline.c | 372 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 372 insertions(+)app/test-pmd/cmdline.c +2
-0@@ -575,6 +575,18 @@ static void cmd_help_long_parsed(void *parsed_result,"E-tag set filter del e-tag-id (value) port (port_id)\n" " Delete an E-tag forwarding filter on a port\n\n" +"ptype mapping get (port_id) (valid_only)\n" +" Get ptype mapping on a port\n\n"
app/test-pmd/cmdline.c static void cmd_help_long_parsed(void *parsed_result, · line 589
Quoted 10 lines
app/test-pmd/cmdline.c +10
-0+ +"ptype mapping replace (port_id) (target) (mask) (pky_type)\n" +" Replace target with the pkt_type in ptype mapping\n\n" + +"ptype mapping reset (port_id)\n" +" Reset ptype mapping on a port\n\n" + +"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" +" Update a ptype mapping item on a port\n\n" +
This adds new root level "ptype" command, I think it would be nice to get an Ack from testpmd maintainers for this.
testpmd now supports many commands, and I don't know if it is only me, but I am having hard time to find some commands. Perhaps commands can be grouped better.
Quoted 6 lines
app/test-pmd/cmdline.c +0
-0, list_pkt_forwarding_modes() ); }@@ -12395,6 +12407,362 @@ cmdline_parse_inst_t cmd_set_vf_vlan_tag = { }, };
<...>
Quoted 4 lines
app/test-pmd/cmdline.c +4
-0+static void +cmd_ptype_mapping_get_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl,
app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_set_vf_vlan_tag = { · line 12456
Quoted 10 lines
app/test-pmd/cmdline.c +10
-0+ __attribute__((unused)) void *data) +{ +struct cmd_ptype_mapping_get_result *res = parsed_result; +#ifdef RTE_LIBRTE_I40E_PMD +int ret = -ENOTSUP ; +int max_ptype_num =256 ; +struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; +uint16_t count; +int i; +#endif
This will cause a build error if I40E driver not enabled. Only wrapping the API with #ifdef should be enough.
Quoted 34 lines
app/test-pmd/cmdline.c +34
-0+ +if (port_id_is_invalid (res->port_id,ENABLED_WARN )) +return ; + +#ifdef RTE_LIBRTE_I40E_PMD + ret =rte_pmd_i40e_ptype_mapping_get (res->port_id, + mapping, + max_ptype_num, + &count, + res->valid_only); +#endif + +switch (ret) { +case 0 : +break ; +case -ENODEV : +printf ("invalid port_id %d\n" , res->port_id); +break ; +case -ENOTSUP : +printf ("function not implemented\n" ); +break ; +default : +printf ("programming error: (%s)\n" ,strerror (-ret)); + } + +#ifdef RTE_LIBRTE_I40E_PMD +if (!ret) { +for (i =0 ; i < count; i++) +printf ("%3d\t0x%08x\n" , + mapping[i].hw_ptype, mapping[i].sw_ptype); + } +#endif +} +
<...>
Re: [PATCH v2 3/3] app/testpmd: add CL for ptype mapping configure
Hi Ferruh:
Quoted 47 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, March 17, 2017 12:27 AM
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Helin <[email protected]>
Cc: [email protected]; De Lara Guarch, Pablo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 3/3] app/testpmd: add CL for ptype mapping configureapp/test-pmd/cmdline.c static void cmd_help_long_parsed(void
Quoted 17 lines · Qi Zhang
Add below command line to configure ptype mapping. ptype mapping get <
port_id> <valid_only>.
ptype mapping replace <port_id> <target> <mask> <pkt_type>. ptype mapping reset <port_id>.
ptype mapping update <port_id> <hw_ptype> <sw_ptype>.Signed-off-by Qi Zhang <[email protected]>--- app/test-pmd/cmdline.c | 372 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 372 insertions(+)app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0
-043fc636..85f07ba 100644
app/test-pmd/cmdline.c +0
-0@@ -575,6 +575,18 @@ static void cmd_help_long_parsed(void
*parsed_result,Quoted 5 lines
app/test-pmd/cmdline.c +2
-0"E-tag set filter del e-tag-id (value) port (port_id)\n" " Delete an E-tag forwarding filter on a port\n\n" +"ptype mapping get (port_id) (valid_only)\n" +" Get ptype mapping on a port\n\n" app/test-pmd/cmdline.c static void cmd_help_long_parsed(void *parsed_result, · line 589
Quoted 10 lines
app/test-pmd/cmdline.c +10
-0+ +"ptype mapping replace (port_id) (target) (mask) (pky_type)\n" +" Replace target with the pkt_type in ptype mapping\n\n" + +"ptype mapping reset (port_id)\n" +" Reset ptype mapping on a port\n\n" + +"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" +" Update a ptype mapping item on a port\n\n" +This adds new root level "ptype" command, I think it would be nice to get an Ack from testpmd maintainers for this.
Quoted 3 lines
testpmd now supports many commands, and I don't know if it is only me, but I am having hard time to find some commands. Perhaps commands can be grouped better.
Yes, I saw so many command in "config" category , maybe we can split these commands into more specific functions.
Quoted 20 lines
app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_set_vf_vlan_tag
Quoted 5 lines
app/test-pmd/cmdline.c +0
-0, list_pkt_forwarding_modes() ); }@@ -12395,6 +12407,362 @@ cmdline_parse_inst_t cmd_set_vf_vlan_tag= {
Quoted 2 lines
app/test-pmd/cmdline.c +0
-0}, };<...>
Quoted 9 lines
app/test-pmd/cmdline.c +9
-0+static void +cmd_ptype_mapping_get_parsed ( +void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_ptype_mapping_get_result *res = parsed_result;#ifdef +RTE_LIBRTE_I40E_PMD +int ret = -ENOTSUP ;
Quoted 8 lines
app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_set_vf_vlan_tag = { · line 12456
Quoted 5 lines
app/test-pmd/cmdline.c +5
-0+int max_ptype_num =256 ; +struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; +uint16_t count; +int i; +#endif This will cause a build error if I40E driver not enabled. Only wrapping the API with #ifdef should be enough.
Will fix it, thanks.
Quoted 37 lines
Quoted 35 lines
app/test-pmd/cmdline.c +34
-0+ +if (port_id_is_invalid (res->port_id,ENABLED_WARN )) +return ; + +#ifdef RTE_LIBRTE_I40E_PMD + ret =rte_pmd_i40e_ptype_mapping_get (res->port_id, + mapping, + max_ptype_num, + &count, + res->valid_only); +#endif + +switch (ret) { +case 0 : +break ; +case -ENODEV : +printf ("invalid port_id %d\n" , res->port_id); +break ; +case -ENOTSUP : +printf ("function not implemented\n" ); +break ; +default : +printf ("programming error: (%s)\n" ,strerror (-ret)); + } + +#ifdef RTE_LIBRTE_I40E_PMD +if (!ret) { +for (i =0 ; i < count; i++) +printf ("%3d\t0x%08x\n" , + mapping[i].hw_ptype, mapping[i].sw_ptype); + } +#endif +} +<...>
Re: [PATCH v2 3/3] app/testpmd: add CL for ptype mapping configure
In reply to Ferruh YigitQuoted 52 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, March 17, 2017 12:27 AM
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Helin <[email protected]>
Cc: [email protected]; De Lara Guarch, Pablo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 3/3] app/testpmd: add CL for ptype mapping configureapp/test-pmd/cmdline.c static void cmd_help_long_parsed(void
Quoted 17 lines · Qi Zhang
Add below command line to configure ptype mapping. ptype mapping get <
port_id> <valid_only>.
ptype mapping replace <port_id> <target> <mask> <pkt_type>. ptype mapping reset <port_id>.
ptype mapping update <port_id> <hw_ptype> <sw_ptype>.Signed-off-by Qi Zhang <[email protected]>--- app/test-pmd/cmdline.c | 372 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 372 insertions(+)app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0
-043fc636..85f07ba 100644
app/test-pmd/cmdline.c +0
-0@@ -575,6 +575,18 @@ static void cmd_help_long_parsed(void
*parsed_result,app/test-pmd/cmdline.c static void cmd_help_long_parsed(void *parsed_result,
Quoted 7 lines
app/test-pmd/cmdline.c +4
-0"E-tag set filter del e-tag-id (value) port (port_id)\n" " Delete an E-tag forwarding filter on a port\n\n" +"ptype mapping get (port_id) (valid_only)\n" +" Get ptype mapping on a port\n\n" + + "ptype mapping replace (port_id) (target) (mask)(pky_type)\n"
app/test-pmd/cmdline.c static void cmd_help_long_parsed(void · line 582
Quoted 1 line
app/test-pmd/cmdline.c +1
-0+ " Replace target with the pkt_type in ptypemapping\n\n"
app/test-pmd/cmdline.c static void cmd_help_long_parsed(void *parsed_result,
Quoted 5 lines
app/test-pmd/cmdline.c +5
-0+ +"ptype mapping reset (port_id)\n" +" Reset ptype mapping on a port\n\n" + + "ptype mapping update (port_id) (hw_ptype)(sw_ptype)\n"
app/test-pmd/cmdline.c static void cmd_help_long_parsed(void *parsed_result, · line 589
Quoted 2 lines
app/test-pmd/cmdline.c +2
-0+" Update a ptype mapping item on a port\n\n" +This adds new root level "ptype" command, I think it would be nice to get an Ack from testpmd maintainers for this.
Quoted 3 lines
testpmd now supports many commands, and I don't know if it is only me, but I am having hard time to find some commands. Perhaps commands can be grouped better.
Now following groups are used. I think the most confusing one is config or ports. Too many commands are included in it. But it looks like new group is not necessary for Qi's commands. We need extra work to refine it.
"Help is available for the following sections:\n\n"
" help control : Start and stop forwarding.\n"
" help display : Displaying port, stats and config "
"information.\n"
" help config : Configuration information.\n"
" help ports : Configuring ports.\n"
" help registers : Reading and setting port registers.\n"
" help filters : Filters configuration help.\n"
" help all : All of the above sections.\n\n"
Re: [PATCH v2 3/3] app/testpmd: add CL for ptype mapping configure
Quoted 61 lines · Jingjing
Quoted 52 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, March 17, 2017 12:27 AM
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Helin <[email protected]>
Cc: [email protected]; De Lara Guarch, Pablo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 3/3] app/testpmd: add CL for ptype mapping configureapp/test-pmd/cmdline.c static void cmd_help_long_parsed(void
Quoted 17 lines · Qi Zhang
Add below command line to configure ptype mapping. ptype mapping get <
port_id> <valid_only>.
ptype mapping replace <port_id> <target> <mask> <pkt_type>. ptype mapping reset <port_id>.
ptype mapping update <port_id> <hw_ptype> <sw_ptype>.Signed-off-by Qi Zhang <[email protected]>--- app/test-pmd/cmdline.c | 372 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 372 insertions(+)app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0
-043fc636..85f07ba 100644
app/test-pmd/cmdline.c +0
-0@@ -575,6 +575,18 @@ static void cmd_help_long_parsed(void
*parsed_result,app/test-pmd/cmdline.c static void cmd_help_long_parsed(void *parsed_result,
Quoted 7 lines
app/test-pmd/cmdline.c +4
-0"E-tag set filter del e-tag-id (value) port (port_id)\n" " Delete an E-tag forwarding filter on a port\n\n" +"ptype mapping get (port_id) (valid_only)\n" +" Get ptype mapping on a port\n\n" + + "ptype mapping replace (port_id) (target) (mask)(pky_type)\n"
app/test-pmd/cmdline.c static void cmd_help_long_parsed(void · line 582
Quoted 1 line
app/test-pmd/cmdline.c +1
-0+ " Replace target with the pkt_type in ptypemapping\n\n"
app/test-pmd/cmdline.c static void cmd_help_long_parsed(void *parsed_result,
Quoted 5 lines
app/test-pmd/cmdline.c +5
-0+ +"ptype mapping reset (port_id)\n" +" Reset ptype mapping on a port\n\n" + + "ptype mapping update (port_id) (hw_ptype)(sw_ptype)\n"
app/test-pmd/cmdline.c static void cmd_help_long_parsed(void *parsed_result, · line 589
Quoted 2 lines
app/test-pmd/cmdline.c +2
-0+" Update a ptype mapping item on a port\n\n" +This adds new root level "ptype" command, I think it would be nice to get an Ack from testpmd maintainers for this.
Quoted 3 lines
testpmd now supports many commands, and I don't know if it is only me, but I am having hard time to find some commands. Perhaps commands can be grouped better.
Now following groups are used. I think the most confusing one is config or ports. Too many commands are included in it. But it looks like new group is not necessary for Qi's commands. We need extra work to refine it.
Quoted 10 lines
"Help is available for the following sections:\n\n"
" help control : Start and stop forwarding.\n"
" help display : Displaying port, stats and config "
"information.\n"
" help config : Configuration information.\n"
" help ports : Configuring ports.\n"
" help registers : Reading and setting port registers.\n"
" help filters : Filters configuration help.\n"
" help all : All of the above sections.\n\n"
I don't know about new config group, but I was worried about new root level config option, these mostly makes sense when you add, in limited context, but can be hard to use them later, in whole application level.
If you are OK with new commands, as testpmd maintainer, I don't have any objection.
Thanks,
ferruh