forked from Minki/linux
nfp: prepare for more TX metadata prepend
Subsequent patches will add support for more TX metadata fields. Prepare for this by handling an additional double word - firmware handle as metadata type 7. Signed-off-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
232eeb1f84
commit
5584c0f825
@ -808,24 +808,47 @@ static void nfp_net_tx_xmit_more_flush(struct nfp_net_tx_ring *tx_ring)
|
|||||||
tx_ring->wr_ptr_add = 0;
|
tx_ring->wr_ptr_add = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nfp_net_prep_port_id(struct sk_buff *skb)
|
static int nfp_net_prep_tx_meta(struct sk_buff *skb, u64 tls_handle)
|
||||||
{
|
{
|
||||||
struct metadata_dst *md_dst = skb_metadata_dst(skb);
|
struct metadata_dst *md_dst = skb_metadata_dst(skb);
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
u32 meta_id = 0;
|
||||||
|
int md_bytes;
|
||||||
|
|
||||||
if (likely(!md_dst))
|
if (likely(!md_dst && !tls_handle))
|
||||||
return 0;
|
return 0;
|
||||||
if (unlikely(md_dst->type != METADATA_HW_PORT_MUX))
|
if (unlikely(md_dst && md_dst->type != METADATA_HW_PORT_MUX)) {
|
||||||
|
if (!tls_handle)
|
||||||
return 0;
|
return 0;
|
||||||
|
md_dst = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (unlikely(skb_cow_head(skb, 8)))
|
md_bytes = 4 + !!md_dst * 4 + !!tls_handle * 8;
|
||||||
|
|
||||||
|
if (unlikely(skb_cow_head(skb, md_bytes)))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
data = skb_push(skb, 8);
|
meta_id = 0;
|
||||||
put_unaligned_be32(NFP_NET_META_PORTID, data);
|
data = skb_push(skb, md_bytes) + md_bytes;
|
||||||
put_unaligned_be32(md_dst->u.port_info.port_id, data + 4);
|
if (md_dst) {
|
||||||
|
data -= 4;
|
||||||
|
put_unaligned_be32(md_dst->u.port_info.port_id, data);
|
||||||
|
meta_id = NFP_NET_META_PORTID;
|
||||||
|
}
|
||||||
|
if (tls_handle) {
|
||||||
|
/* conn handle is opaque, we just use u64 to be able to quickly
|
||||||
|
* compare it to zero
|
||||||
|
*/
|
||||||
|
data -= 8;
|
||||||
|
memcpy(data, &tls_handle, sizeof(tls_handle));
|
||||||
|
meta_id <<= NFP_NET_META_FIELD_SIZE;
|
||||||
|
meta_id |= NFP_NET_META_CONN_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
return 8;
|
data -= 4;
|
||||||
|
put_unaligned_be32(meta_id, data);
|
||||||
|
|
||||||
|
return md_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -848,6 +871,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
|
|||||||
struct nfp_net_dp *dp;
|
struct nfp_net_dp *dp;
|
||||||
dma_addr_t dma_addr;
|
dma_addr_t dma_addr;
|
||||||
unsigned int fsize;
|
unsigned int fsize;
|
||||||
|
u64 tls_handle = 0;
|
||||||
u16 qidx;
|
u16 qidx;
|
||||||
|
|
||||||
dp = &nn->dp;
|
dp = &nn->dp;
|
||||||
@ -869,7 +893,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
|
|||||||
return NETDEV_TX_BUSY;
|
return NETDEV_TX_BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
md_bytes = nfp_net_prep_port_id(skb);
|
md_bytes = nfp_net_prep_tx_meta(skb, tls_handle);
|
||||||
if (unlikely(md_bytes < 0))
|
if (unlikely(md_bytes < 0))
|
||||||
goto err_flush;
|
goto err_flush;
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#define NFP_NET_META_MARK 2
|
#define NFP_NET_META_MARK 2
|
||||||
#define NFP_NET_META_PORTID 5
|
#define NFP_NET_META_PORTID 5
|
||||||
#define NFP_NET_META_CSUM 6 /* checksum complete type */
|
#define NFP_NET_META_CSUM 6 /* checksum complete type */
|
||||||
|
#define NFP_NET_META_CONN_HANDLE 7
|
||||||
|
|
||||||
#define NFP_META_PORT_ID_CTRL ~0U
|
#define NFP_META_PORT_ID_CTRL ~0U
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user