net/ice: fix function pointer in multi-process
PATCH 1/1 net/ice: fix function pointer in multi-process
From: Dapeng Yu <[email protected]>
The sharing of function pointer may cause crash of secondary process. This patch fixes it.
--- drivers/net/ice/ice_rxtx.c | 35 +++++++++++++++++++++++------------ drivers/net/ice/ice_rxtx.h | 2 +- 2 files changed, 24 insertions(+), 13 deletions(-)
drivers/net/ice/ice_rxtx.c +23 -12
@@ -205,51 +205,62 @@ ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq,#endif } +static const ice_rxd_to_pkt_fields_t rxd_to_pkt_fields[] = { + [ICE_RXDID_COMMS_AUX_VLAN ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV4 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6_FLOW ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_TCP ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IP_OFFSET ] = ice_rxd_to_pkt_fields_by_comms_aux_v2, + [ICE_RXDID_COMMS_GENERIC ] = ice_rxd_to_pkt_fields_by_comms_generic, + [ICE_RXDID_COMMS_OVS ] = ice_rxd_to_pkt_fields_by_comms_ovs, +}; +void ice_select_rxd_to_pkt_fields_handler (struct ice_rx_queue *rxq,uint32_t rxdid) {switch (rxdid) {case ICE_RXDID_COMMS_AUX_VLAN : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_vlan_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1; + rxq->rxdid =ICE_RXDID_COMMS_AUX_VLAN ;break ;case ICE_RXDID_COMMS_AUX_IPV4 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv4_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1; + rxq->rxdid =ICE_RXDID_COMMS_AUX_IPV4 ;break ;case ICE_RXDID_COMMS_AUX_IPV6 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1; + rxq->rxdid =ICE_RXDID_COMMS_AUX_IPV6 ;break ;case ICE_RXDID_COMMS_AUX_IPV6_FLOW : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1; + rxq->rxdid =ICE_RXDID_COMMS_AUX_IPV6_FLOW ;break ;case ICE_RXDID_COMMS_AUX_TCP : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_tcp_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1; + rxq->rxdid =ICE_RXDID_COMMS_AUX_TCP ;break ;case ICE_RXDID_COMMS_AUX_IP_OFFSET : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ip_offset_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v2; + rxq->rxdid =ICE_RXDID_COMMS_AUX_IP_OFFSET ;break ;case ICE_RXDID_COMMS_GENERIC : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_generic; + rxq->rxdid =ICE_RXDID_COMMS_GENERIC ;break ;case ICE_RXDID_COMMS_OVS : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs; + rxq->rxdid =ICE_RXDID_COMMS_OVS ;break ;default :/* update this according to the RXDID for PROTO_XTR_NONE */ - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs; + rxq->rxdid =ICE_RXDID_COMMS_OVS ;break ; }
@@ -1622,7 +1633,7 @@ ice_rx_scan_hw_ring(struct ice_rx_queue *rxq) mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (mb, &rxdp[j]); - rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); + rxd_to_pkt_fields[rxq->rxdid](rxq, mb, &rxdp[j]);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) { ts_ns = ice_tstamp_convert_32b_64b(hw,
@@ -1939,7 +1950,7 @@ ice_recv_scattered_pkts(void *rx_queue, first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (first_seg, &rxd); - rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); + rxd_to_pkt_fields[rxq->rxdid](rxq, first_seg, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {
@@ -2370,7 +2381,7 @@ ice_recv_pkts(void *rx_queue, rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (rxm, &rxd); - rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); + rxd_to_pkt_fields[rxq->rxdid](rxq, rxm, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {
drivers/net/ice/ice_rxtx.h +1 -1
@@ -89,7 +89,7 @@ struct ice_rx_queue {bool rx_deferred_start;/* don't start this queue in dev start */ uint8_t proto_xtr;/* Protocol extraction from flexible descriptor */ uint64_t xtr_ol_flag;/* Protocol extraction offload flag */ -ice_rxd_to_pkt_fields_t rxd_to_pkt_fields;/* handle FlexiMD by RXDID */ +uint32_t rxdid;/* Receive Flex Descriptor profile ID */ ice_rx_release_mbufs_t rx_rel_mbufs;uint64_t offloads;uint32_t time_high;
Signature · 1 line
2.27.0
Quoted 12 lines
-----Original Message-----
From: stable <[email protected]> On Behalf Of [email protected]
Sent: Thursday, October 21, 2021 11:35
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; [email protected]
Subject: [dpdk-stable] [PATCH] net/ice: fix function pointer in multi-processFrom: Dapeng Yu <[email protected]>
The sharing of function pointer may cause crash of secondary process. This patch fixes it.
Quoted 9 lines
Fixes 7a340b0b4e03 ("net/ice: refactor Rx FlexiMD handling")Signed-off-by Dapeng Yu <[email protected]>--- drivers/net/ice/ice_rxtx.c | 35 +++++++++++++++++++++++------------ drivers/net/ice/ice_rxtx.h | 2 +- 2 files changed, 24 insertions(+), 13 deletions(-)
Basically LGTM. Just some comments.
drivers/net/ice/ice_rxtx.c ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq, · line 208
Quoted 9 lines
drivers/net/ice/ice_rxtx.c +1
-0@@ -205,51 +205,62 @@ ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq,#endif } +static const ice_rxd_to_pkt_fields_t rxd_to_pkt_fields[] = {
Let's rename it as "rxd_to_pkt_fields_ops", the original name looks like a variable. ;-)
drivers/net/ice/ice_rxtx.c ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq, · line 221
Quoted 13 lines
drivers/net/ice/ice_rxtx.c +10
-0+ [ICE_RXDID_COMMS_AUX_VLAN] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV4] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6_FLOW] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_TCP] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IP_OFFSET] = ice_rxd_to_pkt_fields_by_comms_aux_v2, + [ICE_RXDID_COMMS_GENERIC] = ice_rxd_to_pkt_fields_by_comms_generic, + [ICE_RXDID_COMMS_OVS] = ice_rxd_to_pkt_fields_by_comms_ovs, +}; +void ice_select_rxd_to_pkt_fields_handler (struct ice_rx_queue *rxq,uint32_t rxdid) {
Only use:
rxq->rxdid = rxdid;
Then remove all case ICE_RXDID_xxx, just keep the default:
rxq->rxdid = ICE_RXDID_COMMS_OVS;
Quoted 37 lines
drivers/net/ice/ice_rxtx.c +6
-6switch (rxdid) {case ICE_RXDID_COMMS_AUX_VLAN : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_vlan_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1; + rxq->rxdid =ICE_RXDID_COMMS_AUX_VLAN ;break ;case ICE_RXDID_COMMS_AUX_IPV4 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv4_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1; + rxq->rxdid =ICE_RXDID_COMMS_AUX_IPV4 ;break ;case ICE_RXDID_COMMS_AUX_IPV6 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1; + rxq->rxdid =ICE_RXDID_COMMS_AUX_IPV6 ;break ;case ICE_RXDID_COMMS_AUX_IPV6_FLOW : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1; + rxq->rxdid =ICE_RXDID_COMMS_AUX_IPV6_FLOW ;break ;case ICE_RXDID_COMMS_AUX_TCP : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_tcp_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1; + rxq->rxdid =ICE_RXDID_COMMS_AUX_TCP ;break ;case ICE_RXDID_COMMS_AUX_IP_OFFSET : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ip_offset_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v2; + rxq->rxdid =ICE_RXDID_COMMS_AUX_IP_OFFSET ;break ;
drivers/net/ice/ice_rxtx.c ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq, · line 260
Quoted 10 lines
drivers/net/ice/ice_rxtx.c +2
-2case ICE_RXDID_COMMS_GENERIC : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_generic; + rxq->rxdid =ICE_RXDID_COMMS_GENERIC ;break ;case ICE_RXDID_COMMS_OVS : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs; + rxq->rxdid =ICE_RXDID_COMMS_OVS ;break ;
This case ' ICE_RXDID_COMMS_GENERIC ' and ' ICE_RXDID_COMMS_OVS ' can be removed.
Quoted 49 lines
drivers/net/ice/ice_rxtx.c +4
-4default :/* update this according to the RXDID for PROTO_XTR_NONE */ - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs; + rxq->rxdid =ICE_RXDID_COMMS_OVS ;break ; }@@ -1622,7 +1633,7 @@ ice_rx_scan_hw_ring(struct ice_rx_queue *rxq) mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (mb, &rxdp[j]); - rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); + rxd_to_pkt_fields[rxq->rxdid](rxq, mb, &rxdp[j]);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) { ts_ns = ice_tstamp_convert_32b_64b(hw,@@ -1939,7 +1950,7 @@ ice_recv_scattered_pkts(void *rx_queue, first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (first_seg, &rxd); - rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); + rxd_to_pkt_fields[rxq->rxdid](rxq, first_seg, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {@@ -2370,7 +2381,7 @@ ice_recv_pkts(void *rx_queue, rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (rxm, &rxd); - rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); + rxd_to_pkt_fields[rxq->rxdid](rxq, rxm, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {drivers/net/ice/ice_rxtx.h +1
-2@@ -89,7 +89,7 @@ struct ice_rx_queue {bool rx_deferred_start;/* don't start this queue in dev start */ uint8_t proto_xtr;/* Protocol extraction from flexible descriptor */ uint64_t xtr_ol_flag;/* Protocol extraction offload flag */ -ice_rxd_to_pkt_fields_t rxd_to_pkt_fields;/* handle FlexiMD by RXDID */ +uint32_t rxdid;/* Receive Flex Descriptor profile ID */ ice_rx_release_mbufs_t rx_rel_mbufs;uint64_t offloads;uint32_t time_high; --2.27.0
PATCH v2 1/1 net/ice: fix function pointer in multi-process
In reply to [email protected]From: Dapeng Yu <[email protected]>
The sharing of function pointer may cause crash of secondary process.
This patch removes the shared function pointer: "rxd_to_pkt_fields" in the instance of "struct ice_rx_queue" which is shared between primary and secondary process, and uses an index of function pointer array to replace it.
---
V2:
* Remove redundant code
--- drivers/net/ice/ice_rxtx.c | 35 +++++++++++++++++------------------ drivers/net/ice/ice_rxtx.h | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-)
drivers/net/ice/ice_rxtx.c +17 -18
@@ -205,51 +205,50 @@ ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq,#endif } +static const ice_rxd_to_pkt_fields_t rxd_to_pkt_fields_ops[] = { + [ICE_RXDID_COMMS_AUX_VLAN ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV4 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6_FLOW ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_TCP ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IP_OFFSET ] = ice_rxd_to_pkt_fields_by_comms_aux_v2, + [ICE_RXDID_COMMS_GENERIC ] = ice_rxd_to_pkt_fields_by_comms_generic, + [ICE_RXDID_COMMS_OVS ] = ice_rxd_to_pkt_fields_by_comms_ovs, +}; +void ice_select_rxd_to_pkt_fields_handler (struct ice_rx_queue *rxq,uint32_t rxdid) { + rxq->rxdid = rxdid; +switch (rxdid) {case ICE_RXDID_COMMS_AUX_VLAN : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_vlan_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV4 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv4_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV6 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV6_FLOW : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_TCP : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_tcp_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IP_OFFSET : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ip_offset_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v2; -break ; - -case ICE_RXDID_COMMS_GENERIC : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_generic; -break ; - -case ICE_RXDID_COMMS_OVS : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs;break ;default :/* update this according to the RXDID for PROTO_XTR_NONE */ - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs; + rxq->rxdid =ICE_RXDID_COMMS_OVS ;break ; }
@@ -1622,7 +1621,7 @@ ice_rx_scan_hw_ring(struct ice_rx_queue *rxq) mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (mb, &rxdp[j]); - rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, mb, &rxdp[j]);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) { ts_ns = ice_tstamp_convert_32b_64b(hw,
@@ -1939,7 +1938,7 @@ ice_recv_scattered_pkts(void *rx_queue, first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (first_seg, &rxd); - rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, first_seg, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {
@@ -2370,7 +2369,7 @@ ice_recv_pkts(void *rx_queue, rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (rxm, &rxd); - rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {
drivers/net/ice/ice_rxtx.h +1 -1
@@ -89,7 +89,7 @@ struct ice_rx_queue {bool rx_deferred_start;/* don't start this queue in dev start */ uint8_t proto_xtr;/* Protocol extraction from flexible descriptor */ uint64_t xtr_ol_flag;/* Protocol extraction offload flag */ -ice_rxd_to_pkt_fields_t rxd_to_pkt_fields;/* handle FlexiMD by RXDID */ +uint32_t rxdid;/* Receive Flex Descriptor profile ID */ ice_rx_release_mbufs_t rx_rel_mbufs;uint64_t offloads;uint32_t time_high;
Signature · 1 line
2.27.0
Quoted 8 lines
-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Friday, October 22, 2021 16:58
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wang, Haiyue <[email protected]>; Yu, DapengX <[email protected]>; [email protected]
Subject: [PATCH v2] net/ice: fix function pointer in multi-process
Quoted 8 lines
From: Dapeng Yu <[email protected]>
The sharing of function pointer may cause crash of secondary process.
This patch removes the shared function pointer: "
rxd_to_pkt_fields" in the instance of "structice_rx_queue" which is shared between primary and secondary process, and uses an index of function pointer array to replace it.
I think we can simplify it something as:
Use the index value to call the function, instead of the function pointer assignment to save the selection of Receive Flex Descriptor profile ID.
Otherwise the secondary process will run with wrong function address from primary process.
Quoted 65 lines
Fixes 7a340b0b4e03 ("net/ice: refactor Rx FlexiMD handling")Signed-off-by Dapeng Yu <[email protected]>---
V2:
* Remove redundant code--- drivers/net/ice/ice_rxtx.c | 35 +++++++++++++++++------------------ drivers/net/ice/ice_rxtx.h | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-)drivers/net/ice/ice_rxtx.c +13
-5@@ -205,51 +205,50 @@ ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq,#endif } +static const ice_rxd_to_pkt_fields_t rxd_to_pkt_fields_ops[] = { + [ICE_RXDID_COMMS_AUX_VLAN ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV4 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6_FLOW ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_TCP ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IP_OFFSET ] = ice_rxd_to_pkt_fields_by_comms_aux_v2, + [ICE_RXDID_COMMS_GENERIC ] = ice_rxd_to_pkt_fields_by_comms_generic, + [ICE_RXDID_COMMS_OVS ] = ice_rxd_to_pkt_fields_by_comms_ovs, +}; +void ice_select_rxd_to_pkt_fields_handler (struct ice_rx_queue *rxq,uint32_t rxdid) { + rxq->rxdid = rxdid; +switch (rxdid) {case ICE_RXDID_COMMS_AUX_VLAN : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_vlan_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV4 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv4_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV6 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV6_FLOW : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_TCP : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_tcp_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IP_OFFSET : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ip_offset_mask;
drivers/net/ice/ice_rxtx.c ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq, · line 247
Quoted 10 lines
drivers/net/ice/ice_rxtx.c +0
-9- rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v2; -break ; - -case ICE_RXDID_COMMS_GENERIC : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_generic; -break ; - -case ICE_RXDID_COMMS_OVS : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs;break ;
My fault, we need to keep the above case explicitly, otherwise it will be set to default ICE_RXDID_COMMS_OVS. ;-)
case ICE_RXDID_COMMS_GENERIC:
/* fallthrough */ case ICE_RXDID_COMMS_OVS: break;
Quoted 50 lines
drivers/net/ice/ice_rxtx.c +4
-4default :/* update this according to the RXDID for PROTO_XTR_NONE */ - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs; + rxq->rxdid =ICE_RXDID_COMMS_OVS ;break ; }@@ -1622,7 +1621,7 @@ ice_rx_scan_hw_ring(struct ice_rx_queue *rxq) mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (mb, &rxdp[j]); - rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, mb, &rxdp[j]);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) { ts_ns = ice_tstamp_convert_32b_64b(hw,@@ -1939,7 +1938,7 @@ ice_recv_scattered_pkts(void *rx_queue, first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (first_seg, &rxd); - rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, first_seg, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {@@ -2370,7 +2369,7 @@ ice_recv_pkts(void *rx_queue, rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (rxm, &rxd); - rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {drivers/net/ice/ice_rxtx.h +1
-2@@ -89,7 +89,7 @@ struct ice_rx_queue {bool rx_deferred_start;/* don't start this queue in dev start */ uint8_t proto_xtr;/* Protocol extraction from flexible descriptor */ uint64_t xtr_ol_flag;/* Protocol extraction offload flag */ -ice_rxd_to_pkt_fields_t rxd_to_pkt_fields;/* handle FlexiMD by RXDID */ +uint32_t rxdid;/* Receive Flex Descriptor profile ID */ ice_rx_release_mbufs_t rx_rel_mbufs;uint64_t offloads;uint32_t time_high; --2.27.0
PATCH v3 1/1 net/ice: fix function pointer in multi-process
In reply to [email protected]From: Dapeng Yu <[email protected]>
This patch uses the index value to call the function, instead of the function pointer assignment to save the selection of Receive Flex Descriptor profile ID.
Otherwise the secondary process will run with wrong function address from primary process.
---
V2:
* Remove redundant code
V3:
* Fix incorrect switch statements in V2
--- drivers/net/ice/ice_rxtx.c | 32 ++++++++++++++++++-------------- drivers/net/ice/ice_rxtx.h | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-)
drivers/net/ice/ice_rxtx.c +18 -14
@@ -205,51 +205,55 @@ ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq,#endif } +static const ice_rxd_to_pkt_fields_t rxd_to_pkt_fields_ops[] = { + [ICE_RXDID_COMMS_AUX_VLAN ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV4 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6_FLOW ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_TCP ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IP_OFFSET ] = ice_rxd_to_pkt_fields_by_comms_aux_v2, + [ICE_RXDID_COMMS_GENERIC ] = ice_rxd_to_pkt_fields_by_comms_generic, + [ICE_RXDID_COMMS_OVS ] = ice_rxd_to_pkt_fields_by_comms_ovs, +}; +void ice_select_rxd_to_pkt_fields_handler (struct ice_rx_queue *rxq,uint32_t rxdid) { + rxq->rxdid = rxdid; +switch (rxdid) {case ICE_RXDID_COMMS_AUX_VLAN : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_vlan_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV4 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv4_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV6 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV6_FLOW : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_TCP : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_tcp_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IP_OFFSET : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ip_offset_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v2;break ;case ICE_RXDID_COMMS_GENERIC : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_generic;break ;case ICE_RXDID_COMMS_OVS : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs; -break ; - +/* fallthrough */ default :/* update this according to the RXDID for PROTO_XTR_NONE */ - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs; + rxq->rxdid =ICE_RXDID_COMMS_OVS ;break ; }
@@ -1622,7 +1626,7 @@ ice_rx_scan_hw_ring(struct ice_rx_queue *rxq) mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (mb, &rxdp[j]); - rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, mb, &rxdp[j]);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) { ts_ns = ice_tstamp_convert_32b_64b(hw,
@@ -1939,7 +1943,7 @@ ice_recv_scattered_pkts(void *rx_queue, first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (first_seg, &rxd); - rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, first_seg, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {
@@ -2370,7 +2374,7 @@ ice_recv_pkts(void *rx_queue, rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (rxm, &rxd); - rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {
drivers/net/ice/ice_rxtx.h +1 -1
@@ -89,7 +89,7 @@ struct ice_rx_queue {bool rx_deferred_start;/* don't start this queue in dev start */ uint8_t proto_xtr;/* Protocol extraction from flexible descriptor */ uint64_t xtr_ol_flag;/* Protocol extraction offload flag */ -ice_rxd_to_pkt_fields_t rxd_to_pkt_fields;/* handle FlexiMD by RXDID */ +uint32_t rxdid;/* Receive Flex Descriptor profile ID */ ice_rx_release_mbufs_t rx_rel_mbufs;uint64_t offloads;uint32_t time_high;
Signature · 1 line
2.27.0
PATCH v4 1/1 net/ice: fix function pointer in multi-process
From: Dapeng Yu <[email protected]>
This patch uses the index value to call the function, instead of the function pointer assignment to save the selection of Receive Flex Descriptor profile ID.
Otherwise the secondary process will run with wrong function address from primary process.
---
V2:
* Remove redundant code
V3:
* Fix incorrect switch statements in V2
V4:
* Combine similar case statements
--- drivers/net/ice/ice_rxtx.c | 32 ++++++++++++++++++-------------- drivers/net/ice/ice_rxtx.h | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-)
drivers/net/ice/ice_rxtx.c +18 -14
@@ -205,51 +205,55 @@ ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq,#endif } +static const ice_rxd_to_pkt_fields_t rxd_to_pkt_fields_ops[] = { + [ICE_RXDID_COMMS_AUX_VLAN ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV4 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6_FLOW ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_TCP ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IP_OFFSET ] = ice_rxd_to_pkt_fields_by_comms_aux_v2, + [ICE_RXDID_COMMS_GENERIC ] = ice_rxd_to_pkt_fields_by_comms_generic, + [ICE_RXDID_COMMS_OVS ] = ice_rxd_to_pkt_fields_by_comms_ovs, +}; +void ice_select_rxd_to_pkt_fields_handler (struct ice_rx_queue *rxq,uint32_t rxdid) { + rxq->rxdid = rxdid; +switch (rxdid) {case ICE_RXDID_COMMS_AUX_VLAN : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_vlan_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV4 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv4_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV6 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV6_FLOW : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_TCP : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_tcp_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IP_OFFSET : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ip_offset_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v2;break ;case ICE_RXDID_COMMS_GENERIC : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_generic; -break ; - +/* fallthrough */ case ICE_RXDID_COMMS_OVS : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs;break ;default :/* update this according to the RXDID for PROTO_XTR_NONE */ - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs; + rxq->rxdid =ICE_RXDID_COMMS_OVS ;break ; }
@@ -1622,7 +1626,7 @@ ice_rx_scan_hw_ring(struct ice_rx_queue *rxq) mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (mb, &rxdp[j]); - rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, mb, &rxdp[j]);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) { ts_ns = ice_tstamp_convert_32b_64b(hw,
@@ -1939,7 +1943,7 @@ ice_recv_scattered_pkts(void *rx_queue, first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (first_seg, &rxd); - rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, first_seg, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {
@@ -2370,7 +2374,7 @@ ice_recv_pkts(void *rx_queue, rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (rxm, &rxd); - rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &DEV_RX_OFFLOAD_TIMESTAMP ) {
drivers/net/ice/ice_rxtx.h +1 -1
@@ -89,7 +89,7 @@ struct ice_rx_queue {bool rx_deferred_start;/* don't start this queue in dev start */ uint8_t proto_xtr;/* Protocol extraction from flexible descriptor */ uint64_t xtr_ol_flag;/* Protocol extraction offload flag */ -ice_rxd_to_pkt_fields_t rxd_to_pkt_fields;/* handle FlexiMD by RXDID */ +uint32_t rxdid;/* Receive Flex Descriptor profile ID */ ice_rx_release_mbufs_t rx_rel_mbufs;uint64_t offloads;uint32_t time_high;
Signature · 1 line
2.27.0
Quoted 28 lines
-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Monday, October 25, 2021 13:40
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wang, Haiyue <[email protected]>; Yu, DapengX <[email protected]>; [email protected]
Subject: [PATCH v4] net/ice: fix function pointer in multi-processFrom: Dapeng Yu <[email protected]>
This patch uses the index value to call the function, instead of the function pointer assignment to save the selection of Receive Flex Descriptor profile ID.
Otherwise the secondary process will run with wrong function address from primary process.
Fixes 7a340b0b4e03 ("net/ice: refactor Rx FlexiMD handling")Signed-off-by Dapeng Yu <[email protected]>---
V2:
* Remove redundant code
V3:
* Fix incorrect switch statements in V2
V4:
* Combine similar case statements
Quoted 5 lines
--- drivers/net/ice/ice_rxtx.c | 32 ++++++++++++++++++-------------- drivers/net/ice/ice_rxtx.h | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-)
Quoted 2 lines
--
2.27.0
PATCH v5 1/1 net/ice: fix function pointer in multi-process
In reply to [email protected]From: Dapeng Yu <[email protected]>
This patch uses the index value to call the function, instead of the function pointer assignment to save the selection of Receive Flex Descriptor profile ID.
Otherwise the secondary process will run with wrong function address from primary process.
---
V2:
* Remove redundant code
V3:
* Fix incorrect switch statements in V2
V4:
* Combine similar case statements
V5:
* Rebase
--- drivers/net/ice/ice_rxtx.c | 32 ++++++++++++++++++-------------- drivers/net/ice/ice_rxtx.h | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-)
drivers/net/ice/ice_rxtx.c +18 -14
@@ -204,51 +204,55 @@ ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq,#endif } +static const ice_rxd_to_pkt_fields_t rxd_to_pkt_fields_ops[] = { + [ICE_RXDID_COMMS_AUX_VLAN ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV4 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6 ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IPV6_FLOW ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_TCP ] = ice_rxd_to_pkt_fields_by_comms_aux_v1, + [ICE_RXDID_COMMS_AUX_IP_OFFSET ] = ice_rxd_to_pkt_fields_by_comms_aux_v2, + [ICE_RXDID_COMMS_GENERIC ] = ice_rxd_to_pkt_fields_by_comms_generic, + [ICE_RXDID_COMMS_OVS ] = ice_rxd_to_pkt_fields_by_comms_ovs, +}; +void ice_select_rxd_to_pkt_fields_handler (struct ice_rx_queue *rxq,uint32_t rxdid) { + rxq->rxdid = rxdid; +switch (rxdid) {case ICE_RXDID_COMMS_AUX_VLAN : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_vlan_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV4 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv4_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV6 : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IPV6_FLOW : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_TCP : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_tcp_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;break ;case ICE_RXDID_COMMS_AUX_IP_OFFSET : rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ip_offset_mask; - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v2;break ;case ICE_RXDID_COMMS_GENERIC : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_generic; -break ; - +/* fallthrough */ case ICE_RXDID_COMMS_OVS : - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs;break ;default :/* update this according to the RXDID for PROTO_XTR_NONE */ - rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs; + rxq->rxdid =ICE_RXDID_COMMS_OVS ;break ; }
@@ -1608,7 +1612,7 @@ ice_rx_scan_hw_ring(struct ice_rx_queue *rxq) mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxdp[j].wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (mb, &rxdp[j]); - rxq->rxd_to_pkt_fields (rxq, mb, &rxdp[j]); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, mb, &rxdp[j]);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) { ts_ns = ice_tstamp_convert_32b_64b(hw,
@@ -1925,7 +1929,7 @@ ice_recv_scattered_pkts(void *rx_queue, first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (first_seg, &rxd); - rxq->rxd_to_pkt_fields (rxq, first_seg, &rxd); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, first_seg, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) {
@@ -2356,7 +2360,7 @@ ice_recv_pkts(void *rx_queue, rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &rte_le_to_cpu_16 (rxd.wb.ptype_flex_flags0)];ice_rxd_to_vlan_tci (rxm, &rxd); - rxq->rxd_to_pkt_fields (rxq, rxm, &rxd); + rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd); pkt_flags =ice_rxd_error_to_pkt_flags (rx_stat_err0);#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC if (rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) {
drivers/net/ice/ice_rxtx.h +1 -1
@@ -89,7 +89,7 @@ struct ice_rx_queue {bool rx_deferred_start;/* don't start this queue in dev start */ uint8_t proto_xtr;/* Protocol extraction from flexible descriptor */ uint64_t xtr_ol_flag;/* Protocol extraction offload flag */ -ice_rxd_to_pkt_fields_t rxd_to_pkt_fields;/* handle FlexiMD by RXDID */ +uint32_t rxdid;/* Receive Flex Descriptor profile ID */ ice_rx_release_mbufs_t rx_rel_mbufs;uint64_t offloads;uint32_t time_high;
Signature · 1 line
2.27.0
Zhang, Qi Z
AppliedQuoted 16 lines
-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Tuesday, October 26, 2021 9:56 AM
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wang, Haiyue <[email protected]>; Yu, DapengX <[email protected]>; [email protected]
Subject: [PATCH v5] net/ice: fix function pointer in multi-processFrom: Dapeng Yu <[email protected]>
This patch uses the index value to call the function, instead of the function pointer assignment to save the selection of Receive Flex Descriptor profile ID.
Quoted 8 lines
Otherwise the secondary process will run with wrong function address from primary process.
Fixes 7a340b0b4e03 ("net/ice: refactor Rx FlexiMD handling")Signed-off-by Dapeng Yu <[email protected]>Acked-by Haiyue Wang <[email protected]>
Applied to dpdk-next-net-intel.
Thanks
Qi
Hi,
Whether this fix is applicable for VF? I do not see this change ported to VF in DPDK-20.11.4.
Thanks,
Navin Srinivas
Quoted 32 lines · Qi Z
Quoted 11 lines
-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Tuesday, October 26, 2021 9:56 AM
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wang, Haiyue <[email protected]>; Yu, DapengX <[email protected]>; [email protected]
Subject: [PATCH v5] net/ice: fix function pointer in multi-processQuoted 3 lines
From: Dapeng Yu <[email protected]>
This patch uses the index value to call the function, instead of the
function
Quoted 1 line
pointer assignment to save the selection of Receive Flex Descriptor
profile ID.
Quoted 9 lines
Otherwise the secondary process will run with wrong function address from primary process.
Fixes 7a340b0b4e03 ("net/ice: refactor Rx FlexiMD handling")Signed-off-by Dapeng Yu <[email protected]>Acked-by Haiyue Wang <[email protected]>Applied to dpdk-next-net-intel.
Thanks
Qi
Zhang, Qi Z
AppliedWe need a separate fix for AVF which is ongoing.
And DPDK 20.11.4 LTS by default will only backport all the fix that during DPDK 21.11 dev cycle, so you may need to wait for 20.11.5 or just cherry pick by yourself.
Regards
Qi
From: Navin Srinivas <[email protected]>
Sent: Friday, February 25, 2022 2:00 AM
To: Zhang, Qi Z <[email protected]>
Cc: Yu, DapengX <[email protected]>; Yang, Qiming <[email protected]>; [email protected]; Wang, Haiyue <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v5] net/ice: fix function pointer in multi-process
Hi,
Whether this fix is applicable for VF? I do not see this change ported to VF in DPDK-20.11.4.
Thanks,
Navin Srinivas
Quoted 14 lines · On Wed, Oct 27, 2021 at 8:58 AM Zhang, Qi Z…
-----Original Message-----
From: Yu, DapengX <[email protected]<mailto:[email protected]>>
Sent: Tuesday, October 26, 2021 9:56 AM
To: Yang, Qiming <[email protected]<mailto:[email protected]>>; Zhang, Qi Z <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; Wang, Haiyue <[email protected]<mailto:[email protected]>>; Yu, DapengX <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Subject: [PATCH v5] net/ice: fix function pointer in multi-processFrom: Dapeng Yu <[email protected]<mailto:[email protected]>>
This patch uses the index value to call the function, instead of the function pointer assignment to save the selection of Receive Flex Descriptor profile ID.
Quoted 8 lines
Otherwise the secondary process will run with wrong function address from primary process.
Fixes 7a340b0b4e03 ("net/ice: refactor Rx FlexiMD handling")Cc [email protected]<mailto:[email protected]>
Applied to dpdk-next-net-intel.
Thanks
Qi
Hi Qi,
Thank you for your reply and confirmation.
Regards,
Navin Srinivas
Quoted 77 lines · Qi Z
We need a separate fix for AVF which is ongoing.
And DPDK 20.11.4 LTS by default will only backport all the fix that during DPDK 21.11 dev cycle, so you may need to wait for 20.11.5 or just cherry pick by yourself.
Regards
Qi
*From:* Navin Srinivas <[email protected]>
*Sent:* Friday, February 25, 2022 2:00 AM
*To:* Zhang, Qi Z <[email protected]>
*Cc:* Yu, DapengX <[email protected]>; Yang, Qiming < [email protected]>; [email protected]; Wang, Haiyue <[email protected]>; [email protected]
*Subject:* Re: [dpdk-dev] [PATCH v5] net/ice: fix function pointer in multi-processHi,
Whether this fix is applicable for VF? I do not see this change ported to VF in DPDK-20.11.4.
Thanks,
Navin Srinivas
Quoted 9 lines · Qi Z
-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Tuesday, October 26, 2021 9:56 AM
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wang, Haiyue <[email protected]>; Yu, DapengX <[email protected]>; [email protected]
Subject: [PATCH v5] net/ice: fix function pointer in multi-processQuoted 3 lines
From: Dapeng Yu <[email protected]>
This patch uses the index value to call the function, instead of the
function
Quoted 1 line
pointer assignment to save the selection of Receive Flex Descriptor
profile ID.
Quoted 9 lines
Otherwise the secondary process will run with wrong function address from primary process.
Fixes 7a340b0b4e03 ("net/ice: refactor Rx FlexiMD handling")Signed-off-by Dapeng Yu <[email protected]>Acked-by Haiyue Wang <[email protected]>Applied to dpdk-next-net-intel.
Thanks
Qi