Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
12c6c9f
ice: make RX hash reading code more reusable
walking-machine Mar 20, 2023
3a13ad3
ice: make RX HW timestamp reading code more reusable
walking-machine Mar 21, 2023
fcc0aee
ice: make RX checksum checking code more reusable
walking-machine Mar 21, 2023
8e01d7b
ice: Make ptype internal to descriptor info processing
walking-machine Mar 21, 2023
ad9da01
ice: Introduce ice_xdp_buff
walking-machine Mar 23, 2023
d21ce4f
ice: Support HW timestamp hint
walking-machine Mar 23, 2023
94f068f
ice: Support RX hash XDP hint
walking-machine Mar 23, 2023
8a58107
ice: Support XDP hints in AF_XDP ZC mode
walking-machine Mar 23, 2023
735554f
xdp: Add VLAN tag hint
walking-machine Mar 24, 2023
50dedd4
ice: Implement VLAN tag hint
walking-machine Mar 24, 2023
f5ea54f
ice: use VLAN proto from ring packet context in skb path
walking-machine Jun 26, 2023
0662660
xdp: Add checksum level hint
walking-machine Mar 24, 2023
7d2fc44
ice: Implement checksum level hint
walking-machine Mar 24, 2023
8d2ecca
selftests/bpf: Allow VLAN packets in xdp_hw_metadata
walking-machine Apr 17, 2023
5a9951b
net, xdp: allow metadata > 32
alobakin Apr 4, 2022
cce07bf
selftests/bpf: Add flags and new hints to xdp_hw_metadata
walking-machine Apr 20, 2023
63be6f6
veth: Implement VLAN tag and checksum level XDP hint
walking-machine May 31, 2023
79406fa
selftests/bpf: Use AF_INET for TX in xdp_metadata
walking-machine Jun 13, 2023
1dc5a8c
selftests/bpf: Check VLAN tag and proto in xdp_metadata
walking-machine Jun 16, 2023
b974532
selftests/bpf: check checksum level in xdp_metadata
walking-machine Jun 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Documentation/networking/xdp-rx-metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ Currently, the following kfuncs are supported. In the future, as more
metadata is supported, this set will grow:

.. kernel-doc:: net/core/xdp.c
:identifiers: bpf_xdp_metadata_rx_timestamp bpf_xdp_metadata_rx_hash
:identifiers: bpf_xdp_metadata_rx_timestamp

.. kernel-doc:: net/core/xdp.c
:identifiers: bpf_xdp_metadata_rx_hash

.. kernel-doc:: net/core/xdp.c
:identifiers: bpf_xdp_metadata_rx_vlan_tag

.. kernel-doc:: net/core/xdp.c
:identifiers: bpf_xdp_metadata_rx_csum_lvl

An XDP program can use these kfuncs to read the metadata into stack
variables for its own consumption. Or, to pass the metadata on to other
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/intel/ice/ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,6 @@ static inline void ice_clear_rdma_cap(struct ice_pf *pf)
set_bit(ICE_FLAG_UNPLUG_AUX_DEV, pf->flags);
clear_bit(ICE_FLAG_RDMA_ENA, pf->flags);
}

extern const struct xdp_metadata_ops ice_xdp_md_ops;
#endif /* _ICE_H_ */
2 changes: 1 addition & 1 deletion drivers/net/ethernet/intel/ice/ice_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -2837,7 +2837,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring,
/* clone ring and setup updated count */
rx_rings[i] = *vsi->rx_rings[i];
rx_rings[i].count = new_rx_cnt;
rx_rings[i].cached_phctime = pf->ptp.cached_phc_time;
rx_rings[i].pkt_ctx.cached_phctime = pf->ptp.cached_phc_time;
rx_rings[i].desc = NULL;
rx_rings[i].rx_buf = NULL;
/* this is to allow wr32 to have something to write to
Expand Down
412 changes: 208 additions & 204 deletions drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion drivers/net/ethernet/intel/ice/ice_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi)
ring->netdev = vsi->netdev;
ring->dev = dev;
ring->count = vsi->num_rx_desc;
ring->cached_phctime = pf->ptp.cached_phc_time;
ring->pkt_ctx.cached_phctime = pf->ptp.cached_phc_time;
WRITE_ONCE(vsi->rx_rings[i], ring);
}

Expand Down
23 changes: 23 additions & 0 deletions drivers/net/ethernet/intel/ice/ice_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3384,6 +3384,7 @@ static void ice_set_ops(struct ice_vsi *vsi)

netdev->netdev_ops = &ice_netdev_ops;
netdev->udp_tunnel_nic_info = &pf->hw.udp_tunnel_nic;
netdev->xdp_metadata_ops = &ice_xdp_md_ops;
ice_set_ethtool_ops(netdev);

if (vsi->type != ICE_VSI_PF)
Expand Down Expand Up @@ -5929,6 +5930,23 @@ ice_fix_features(struct net_device *netdev, netdev_features_t features)
return features;
}

/**
* ice_set_rx_rings_vlan_proto - update rings with new stripped VLAN proto
* @vsi: PF's VSI
* @vlan_ethertype: VLAN ethertype (802.1Q or 802.1ad) in network byte order
*
* Store current stripped VLAN proto in ring packet context,
* so it can be accessed more efficiently by packet processing code.
*/
static void
ice_set_rx_rings_vlan_proto(struct ice_vsi *vsi, __be16 vlan_ethertype)
{
u16 i;

ice_for_each_alloc_rxq(vsi, i)
vsi->rx_rings[i]->pkt_ctx.vlan_proto = vlan_ethertype;
}

/**
* ice_set_vlan_offload_features - set VLAN offload features for the PF VSI
* @vsi: PF's VSI
Expand Down Expand Up @@ -5971,6 +5989,11 @@ ice_set_vlan_offload_features(struct ice_vsi *vsi, netdev_features_t features)
if (strip_err || insert_err)
return -EIO;

if (enable_stripping)
ice_set_rx_rings_vlan_proto(vsi, htons(vlan_ethertype));
else
ice_set_rx_rings_vlan_proto(vsi, 0);

return 0;
}

Expand Down
26 changes: 9 additions & 17 deletions drivers/net/ethernet/intel/ice/ice_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ static int ice_ptp_update_cached_phctime(struct ice_pf *pf)
ice_for_each_rxq(vsi, j) {
if (!vsi->rx_rings[j])
continue;
WRITE_ONCE(vsi->rx_rings[j]->cached_phctime, systime);
WRITE_ONCE(vsi->rx_rings[j]->pkt_ctx.cached_phctime, systime);
}
}
clear_bit(ICE_CFG_BUSY, pf->state);
Expand Down Expand Up @@ -2147,30 +2147,24 @@ int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr)
}

/**
* ice_ptp_rx_hwtstamp - Check for an Rx timestamp
* @rx_ring: Ring to get the VSI info
* ice_ptp_get_rx_hwts - Get packet Rx timestamp
* @rx_desc: Receive descriptor
* @skb: Particular skb to send timestamp with
* @cached_time: Cached PHC time
*
* The driver receives a notification in the receive descriptor with timestamp.
* The timestamp is in ns, so we must convert the result first.
*/
void
ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring,
union ice_32b_rx_flex_desc *rx_desc, struct sk_buff *skb)
u64 ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc,
u64 cached_time)
{
struct skb_shared_hwtstamps *hwtstamps;
u64 ts_ns, cached_time;
u32 ts_high;
u64 ts_ns;

if (!(rx_desc->wb.time_stamp_low & ICE_PTP_TS_VALID))
return;

cached_time = READ_ONCE(rx_ring->cached_phctime);
return 0;

/* Do not report a timestamp if we don't have a cached PHC time */
if (!cached_time)
return;
return 0;

/* Use ice_ptp_extend_32b_ts directly, using the ring-specific cached
* PHC value, rather than accessing the PF. This also allows us to
Expand All @@ -2181,9 +2175,7 @@ ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring,
ts_high = le32_to_cpu(rx_desc->wb.flex_ts.ts_high);
ts_ns = ice_ptp_extend_32b_ts(cached_time, ts_high);

hwtstamps = skb_hwtstamps(skb);
memset(hwtstamps, 0, sizeof(*hwtstamps));
hwtstamps->hwtstamp = ns_to_ktime(ts_ns);
return ts_ns;
}

/**
Expand Down
15 changes: 9 additions & 6 deletions drivers/net/ethernet/intel/ice/ice_ptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,8 @@ void ice_ptp_extts_event(struct ice_pf *pf);
s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb);
enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf);

void
ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring,
union ice_32b_rx_flex_desc *rx_desc, struct sk_buff *skb);
u64 ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc,
u64 cached_time);
void ice_ptp_reset(struct ice_pf *pf);
void ice_ptp_prepare_for_reset(struct ice_pf *pf);
void ice_ptp_init(struct ice_pf *pf);
Expand Down Expand Up @@ -304,9 +303,13 @@ static inline bool ice_ptp_process_ts(struct ice_pf *pf)
{
return true;
}
static inline void
ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring,
union ice_32b_rx_flex_desc *rx_desc, struct sk_buff *skb) { }

static inline u64
ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc, u64 cached_time)
{
return 0;
}

static inline void ice_ptp_reset(struct ice_pf *pf) { }
static inline void ice_ptp_prepare_for_reset(struct ice_pf *pf) { }
static inline void ice_ptp_init(struct ice_pf *pf) { }
Expand Down
15 changes: 7 additions & 8 deletions drivers/net/ethernet/intel/ice/ice_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,20 +557,23 @@ ice_rx_frame_truesize(struct ice_rx_ring *rx_ring, const unsigned int size)
* @xdp_prog: XDP program to run
* @xdp_ring: ring to be used for XDP_TX action
* @rx_buf: Rx buffer to store the XDP action
* @eop_desc: Last descriptor in packet to read metadata from
*
* Returns any of ICE_XDP_{PASS, CONSUMED, TX, REDIR}
*/
static void
ice_run_xdp(struct ice_rx_ring *rx_ring, struct xdp_buff *xdp,
struct bpf_prog *xdp_prog, struct ice_tx_ring *xdp_ring,
struct ice_rx_buf *rx_buf)
struct ice_rx_buf *rx_buf, union ice_32b_rx_flex_desc *eop_desc)
{
unsigned int ret = ICE_XDP_PASS;
u32 act;

if (!xdp_prog)
goto exit;

ice_xdp_meta_set_desc(xdp, eop_desc);

act = bpf_prog_run_xdp(xdp_prog, xdp);
switch (act) {
case XDP_PASS:
Expand Down Expand Up @@ -1181,7 +1184,6 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
unsigned int size;
u16 stat_err_bits;
u16 vlan_tag = 0;
u16 rx_ptype;

/* get the Rx desc from Rx ring based on 'next_to_clean' */
rx_desc = ICE_RX_DESC(rx_ring, ntc);
Expand Down Expand Up @@ -1241,7 +1243,7 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
if (ice_is_non_eop(rx_ring, rx_desc))
continue;

ice_run_xdp(rx_ring, xdp, xdp_prog, xdp_ring, rx_buf);
ice_run_xdp(rx_ring, xdp, xdp_prog, xdp_ring, rx_buf, rx_desc);
if (rx_buf->act == ICE_XDP_PASS)
goto construct_skb;
total_rx_bytes += xdp_get_buff_len(xdp);
Expand Down Expand Up @@ -1276,7 +1278,7 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
continue;
}

vlan_tag = ice_get_vlan_tag_from_rx_desc(rx_desc);
vlan_tag = ice_get_vlan_tag(rx_desc);

/* pad the skb if needed, to make a valid ethernet frame */
if (eth_skb_pad(skb))
Expand All @@ -1286,10 +1288,7 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
total_rx_bytes += skb->len;

/* populate checksum, VLAN, and protocol */
rx_ptype = le16_to_cpu(rx_desc->wb.ptype_flex_flags0) &
ICE_RX_FLEX_DESC_PTYPE_M;

ice_process_skb_fields(rx_ring, rx_desc, skb, rx_ptype);
ice_process_skb_fields(rx_ring, rx_desc, skb);

ice_trace(clean_rx_irq_indicate, rx_ring, rx_desc, skb);
/* send completed skb up the stack */
Expand Down
29 changes: 25 additions & 4 deletions drivers/net/ethernet/intel/ice/ice_txrx.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,20 @@ enum ice_rx_dtype {
ICE_RX_DTYPE_SPLIT_ALWAYS = 2,
};

struct ice_pkt_ctx {
const union ice_32b_rx_flex_desc *eop_desc;
u64 cached_phctime;
__be16 vlan_proto;
};

struct ice_xdp_buff {
struct xdp_buff xdp_buff;
struct ice_pkt_ctx pkt_ctx;
};

/* Required for compatibility with xdp_buffs from xsk_pool */
static_assert(offsetof(struct ice_xdp_buff, xdp_buff) == 0);

/* indices into GLINT_ITR registers */
#define ICE_RX_ITR ICE_IDX_ITR0
#define ICE_TX_ITR ICE_IDX_ITR1
Expand Down Expand Up @@ -298,7 +312,6 @@ enum ice_dynamic_itr {
/* descriptor ring, associated with a VSI */
struct ice_rx_ring {
/* CL1 - 1st cacheline starts here */
struct ice_rx_ring *next; /* pointer to next ring in q_vector */
void *desc; /* Descriptor ring memory */
struct device *dev; /* Used for DMA mapping */
struct net_device *netdev; /* netdev ring maps to */
Expand All @@ -310,12 +323,19 @@ struct ice_rx_ring {
u16 count; /* Number of descriptors */
u16 reg_idx; /* HW register index of the ring */
u16 next_to_alloc;
/* CL2 - 2nd cacheline starts here */

union {
struct ice_rx_buf *rx_buf;
struct xdp_buff **xdp_buf;
};
struct xdp_buff xdp;
/* CL2 - 2nd cacheline starts here */
union {
struct ice_xdp_buff xdp_ext;
struct {
struct xdp_buff xdp;
struct ice_pkt_ctx pkt_ctx;
};
};
/* CL3 - 3rd cacheline starts here */
struct bpf_prog *xdp_prog;
u16 rx_offset;
Expand All @@ -325,6 +345,8 @@ struct ice_rx_ring {
u16 next_to_clean;
u16 first_desc;

struct ice_rx_ring *next; /* pointer to next ring in q_vector */

/* stats structs */
struct ice_ring_stats *ring_stats;

Expand All @@ -334,7 +356,6 @@ struct ice_rx_ring {
struct ice_tx_ring *xdp_ring;
struct xsk_buff_pool *xsk_pool;
dma_addr_t dma; /* physical address of ring */
u64 cached_phctime;
u16 rx_buf_len;
u8 dcb_tc; /* Traffic class of ring */
u8 ptp_rx;
Expand Down
Loading