From: Long Wu <long...@corigine.com> Using the Rx packet offload flag rather than the device capability to control the packet type offload configuration. Also implement the device packet type set interface to let application can set the Rx packet offload flag.
Signed-off-by: Long Wu <long...@corigine.com> Reviewed-by: Chaoyong He <chaoyong...@corigine.com> --- V2: * Following the advice from reviewer, abandon the modification of RTE layer. --- drivers/net/nfp/nfp_ethdev.c | 1 + drivers/net/nfp/nfp_net_common.c | 42 +++++++++++++++++++++++++++++++- drivers/net/nfp/nfp_net_common.h | 1 + 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index bd35df2dc9..09c15eedac 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -932,6 +932,7 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = { .xstats_get_names_by_id = nfp_net_xstats_get_names_by_id, .dev_infos_get = nfp_net_infos_get, .dev_supported_ptypes_get = nfp_net_supported_ptypes_get, + .dev_ptypes_set = nfp_net_ptypes_set, .mtu_set = nfp_net_dev_mtu_set, .mac_addr_set = nfp_net_set_mac_addr, .vlan_offload_set = nfp_net_vlan_offload_set, diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 3d916cd147..0b71d55366 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -1459,13 +1459,53 @@ nfp_net_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements) return NULL; net_hw = dev->data->dev_private; - if ((net_hw->super.ctrl_ext & NFP_NET_CFG_CTRL_PKT_TYPE) == 0) + if ((net_hw->super.cap_ext & NFP_NET_CFG_CTRL_PKT_TYPE) == 0) return NULL; *no_of_elements = RTE_DIM(ptypes); return ptypes; } +int +nfp_net_ptypes_set(struct rte_eth_dev *dev, + uint32_t ptype_mask) +{ + int ret; + uint32_t update; + uint32_t ctrl_ext; + struct nfp_hw *hw; + struct nfp_net_hw *net_hw; + + net_hw = dev->data->dev_private; + hw = &net_hw->super; + + if ((hw->cap_ext & NFP_NET_CFG_CTRL_PKT_TYPE) == 0) + return -ENOTSUP; + + ctrl_ext = hw->ctrl_ext; + if (ptype_mask == 0) { + if ((ctrl_ext & NFP_NET_CFG_CTRL_PKT_TYPE) == 0) + return 0; + + ctrl_ext &= ~NFP_NET_CFG_CTRL_PKT_TYPE; + } else { + if ((ctrl_ext & NFP_NET_CFG_CTRL_PKT_TYPE) != 0) + return 0; + + ctrl_ext |= NFP_NET_CFG_CTRL_PKT_TYPE; + } + + update = NFP_NET_CFG_UPDATE_GEN; + + ret = nfp_ext_reconfig(hw, ctrl_ext, update); + if (ret != 0) + return ret; + + hw->ctrl_ext = ctrl_ext; + + return 0; +} + int nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index bebb754ced..3c4d305b01 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -315,6 +315,7 @@ int nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); const uint32_t *nfp_net_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements); +int nfp_net_ptypes_set(struct rte_eth_dev *dev, uint32_t ptype_mask); int nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id); int nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id); void nfp_net_params_setup(struct nfp_net_hw *hw); -- 2.39.1