Skip to content

Commit

Permalink
net/nfp: implement the device packet type set interface
Browse files Browse the repository at this point in the history
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.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
  • Loading branch information
wulong2022 authored and ferruhy committed Sep 27, 2024
1 parent 46d738c commit 64ad195
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/guides/nics/features/nfp.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ QinQ offload = Y
FEC = Y
L3 checksum offload = Y
L4 checksum offload = Y
Packet type parsing = Y
Basic stats = Y
Stats per queue = Y
Linux = Y
Expand Down
1 change: 1 addition & 0 deletions drivers/net/nfp/nfp_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
42 changes: 41 additions & 1 deletion drivers/net/nfp/nfp_net_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions drivers/net/nfp/nfp_net_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 64ad195

Please sign in to comment.