Skip to content

Commit

Permalink
net/nfp: fix NFDk metadata process
Browse files Browse the repository at this point in the history
The Tx function can not check if the metadata process success for
the process function with void return type.

Fix it by change the return type of the metadata function from
void to integer and add the error handle logic in the Tx function.

Fixes: 7c82b86 ("net/nfp: support VLAN insert with NFDk")
Cc: [email protected]

Signed-off-by: Chaoyong He <[email protected]>
Reviewed-by: Long Wu <[email protected]>
Reviewed-by: Peng Zhang <[email protected]>
  • Loading branch information
hechaoyong authored and ferruhy committed Feb 21, 2024
1 parent 7ecf3b9 commit b36f0b1
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions drivers/net/nfp/nfdk/nfp_nfdk_dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq,
return nop_slots;
}

static void
static int
nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
struct nfp_net_txq *txq,
uint64_t *metadata)
Expand Down Expand Up @@ -206,8 +206,10 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
meta_data.length += 3 * NFP_NET_META_FIELD_SIZE;
}

if (meta_data.length == 0)
return;
if (meta_data.length == 0) {
*metadata = 0;
return 0;
}

meta_type = meta_data.header;
header_offset = meta_type << NFP_NET_META_NFDK_LENGTH;
Expand All @@ -223,29 +225,32 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
case NFP_NET_META_VLAN:
if (vlan_layer > 0) {
PMD_DRV_LOG(ERR, "At most 1 layers of vlan is supported");
return;
return -EINVAL;
}

nfp_net_set_meta_vlan(&meta_data, pkt, layer);
vlan_layer++;
break;
case NFP_NET_META_IPSEC:
if (ipsec_layer > 2) {
PMD_DRV_LOG(ERR, "At most 3 layers of ipsec is supported for now.");
return;
return -EINVAL;
}

nfp_net_set_meta_ipsec(&meta_data, txq, pkt, layer, ipsec_layer);
ipsec_layer++;
break;
default:
PMD_DRV_LOG(ERR, "The metadata type not supported");
return;
return -ENOTSUP;
}

memcpy(meta, &meta_data.data[layer], sizeof(meta_data.data[layer]));
}

*metadata = NFDK_DESC_TX_CHAIN_META;

return 0;
}

uint16_t
Expand Down Expand Up @@ -292,6 +297,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,

/* Sending packets */
while (npkts < nb_pkts && free_descs > 0) {
int ret;
int nop_descs;
uint32_t type;
uint32_t dma_len;
Expand Down Expand Up @@ -319,10 +325,13 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,

temp_pkt = pkt;

if (repr_flag)
if (repr_flag) {
metadata = NFDK_DESC_TX_CHAIN_META;
else
nfp_net_nfdk_set_meta_data(pkt, txq, &metadata);
} else {
ret = nfp_net_nfdk_set_meta_data(pkt, txq, &metadata);
if (unlikely(ret != 0))
goto xmit_end;
}

if (unlikely(pkt->nb_segs > 1 &&
(hw->super.ctrl & NFP_NET_CFG_CTRL_GATHER) == 0)) {
Expand Down

0 comments on commit b36f0b1

Please sign in to comment.