Skip to content

Commit ce5cf4a

Browse files
halfboy93anguy11
authored andcommitted
libeth: move idpf_rx_csum_decoded and idpf_rx_extracted
Structs idpf_rx_csum_decoded and idpf_rx_extracted are used both in idpf and iavf Intel drivers. Change the prefix from idpf_* to libeth_* and move mentioned structs to libeth's rx.h header file. Adjust usage in idpf driver. Suggested-by: Alexander Lobakin <aleksander.lobakin@intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 7c01dbf commit ce5cf4a

File tree

4 files changed

+82
-51
lines changed

4 files changed

+82
-51
lines changed

drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ static bool idpf_rx_singleq_is_non_eop(const union virtchnl2_rx_desc *rx_desc)
595595
*/
596596
static void idpf_rx_singleq_csum(struct idpf_rx_queue *rxq,
597597
struct sk_buff *skb,
598-
struct idpf_rx_csum_decoded csum_bits,
598+
struct libeth_rx_csum csum_bits,
599599
struct libeth_rx_pt decoded)
600600
{
601601
bool ipv4, ipv6;
@@ -661,10 +661,10 @@ static void idpf_rx_singleq_csum(struct idpf_rx_queue *rxq,
661661
*
662662
* Return: parsed checksum status.
663663
**/
664-
static struct idpf_rx_csum_decoded
664+
static struct libeth_rx_csum
665665
idpf_rx_singleq_base_csum(const union virtchnl2_rx_desc *rx_desc)
666666
{
667-
struct idpf_rx_csum_decoded csum_bits = { };
667+
struct libeth_rx_csum csum_bits = { };
668668
u32 rx_error, rx_status;
669669
u64 qword;
670670

@@ -696,10 +696,10 @@ idpf_rx_singleq_base_csum(const union virtchnl2_rx_desc *rx_desc)
696696
*
697697
* Return: parsed checksum status.
698698
**/
699-
static struct idpf_rx_csum_decoded
699+
static struct libeth_rx_csum
700700
idpf_rx_singleq_flex_csum(const union virtchnl2_rx_desc *rx_desc)
701701
{
702-
struct idpf_rx_csum_decoded csum_bits = { };
702+
struct libeth_rx_csum csum_bits = { };
703703
u16 rx_status0, rx_status1;
704704

705705
rx_status0 = le16_to_cpu(rx_desc->flex_nic_wb.status_error0);
@@ -798,7 +798,7 @@ idpf_rx_singleq_process_skb_fields(struct idpf_rx_queue *rx_q,
798798
u16 ptype)
799799
{
800800
struct libeth_rx_pt decoded = rx_q->rx_ptype_lkup[ptype];
801-
struct idpf_rx_csum_decoded csum_bits;
801+
struct libeth_rx_csum csum_bits;
802802

803803
/* modifies the skb - consumes the enet header */
804804
skb->protocol = eth_type_trans(skb, rx_q->netdev);
@@ -891,6 +891,7 @@ bool idpf_rx_singleq_buf_hw_alloc_all(struct idpf_rx_queue *rx_q,
891891
* idpf_rx_singleq_extract_base_fields - Extract fields from the Rx descriptor
892892
* @rx_desc: the descriptor to process
893893
* @fields: storage for extracted values
894+
* @ptype: pointer that will store packet type
894895
*
895896
* Decode the Rx descriptor and extract relevant information including the
896897
* size and Rx packet type.
@@ -900,20 +901,21 @@ bool idpf_rx_singleq_buf_hw_alloc_all(struct idpf_rx_queue *rx_q,
900901
*/
901902
static void
902903
idpf_rx_singleq_extract_base_fields(const union virtchnl2_rx_desc *rx_desc,
903-
struct idpf_rx_extracted *fields)
904+
struct libeth_rqe_info *fields, u32 *ptype)
904905
{
905906
u64 qword;
906907

907908
qword = le64_to_cpu(rx_desc->base_wb.qword1.status_error_ptype_len);
908909

909-
fields->size = FIELD_GET(VIRTCHNL2_RX_BASE_DESC_QW1_LEN_PBUF_M, qword);
910-
fields->rx_ptype = FIELD_GET(VIRTCHNL2_RX_BASE_DESC_QW1_PTYPE_M, qword);
910+
fields->len = FIELD_GET(VIRTCHNL2_RX_BASE_DESC_QW1_LEN_PBUF_M, qword);
911+
*ptype = FIELD_GET(VIRTCHNL2_RX_BASE_DESC_QW1_PTYPE_M, qword);
911912
}
912913

913914
/**
914915
* idpf_rx_singleq_extract_flex_fields - Extract fields from the Rx descriptor
915916
* @rx_desc: the descriptor to process
916917
* @fields: storage for extracted values
918+
* @ptype: pointer that will store packet type
917919
*
918920
* Decode the Rx descriptor and extract relevant information including the
919921
* size and Rx packet type.
@@ -923,30 +925,31 @@ idpf_rx_singleq_extract_base_fields(const union virtchnl2_rx_desc *rx_desc,
923925
*/
924926
static void
925927
idpf_rx_singleq_extract_flex_fields(const union virtchnl2_rx_desc *rx_desc,
926-
struct idpf_rx_extracted *fields)
928+
struct libeth_rqe_info *fields, u32 *ptype)
927929
{
928-
fields->size = FIELD_GET(VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M,
929-
le16_to_cpu(rx_desc->flex_nic_wb.pkt_len));
930-
fields->rx_ptype = FIELD_GET(VIRTCHNL2_RX_FLEX_DESC_PTYPE_M,
931-
le16_to_cpu(rx_desc->flex_nic_wb.ptype_flex_flags0));
930+
fields->len = FIELD_GET(VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M,
931+
le16_to_cpu(rx_desc->flex_nic_wb.pkt_len));
932+
*ptype = FIELD_GET(VIRTCHNL2_RX_FLEX_DESC_PTYPE_M,
933+
le16_to_cpu(rx_desc->flex_nic_wb.ptype_flex_flags0));
932934
}
933935

934936
/**
935937
* idpf_rx_singleq_extract_fields - Extract fields from the Rx descriptor
936938
* @rx_q: Rx descriptor queue
937939
* @rx_desc: the descriptor to process
938940
* @fields: storage for extracted values
941+
* @ptype: pointer that will store packet type
939942
*
940943
*/
941944
static void
942945
idpf_rx_singleq_extract_fields(const struct idpf_rx_queue *rx_q,
943946
const union virtchnl2_rx_desc *rx_desc,
944-
struct idpf_rx_extracted *fields)
947+
struct libeth_rqe_info *fields, u32 *ptype)
945948
{
946949
if (rx_q->rxdids == VIRTCHNL2_RXDID_1_32B_BASE_M)
947-
idpf_rx_singleq_extract_base_fields(rx_desc, fields);
950+
idpf_rx_singleq_extract_base_fields(rx_desc, fields, ptype);
948951
else
949-
idpf_rx_singleq_extract_flex_fields(rx_desc, fields);
952+
idpf_rx_singleq_extract_flex_fields(rx_desc, fields, ptype);
950953
}
951954

952955
/**
@@ -966,9 +969,10 @@ static int idpf_rx_singleq_clean(struct idpf_rx_queue *rx_q, int budget)
966969

967970
/* Process Rx packets bounded by budget */
968971
while (likely(total_rx_pkts < (unsigned int)budget)) {
969-
struct idpf_rx_extracted fields = { };
972+
struct libeth_rqe_info fields = { };
970973
union virtchnl2_rx_desc *rx_desc;
971974
struct idpf_rx_buf *rx_buf;
975+
u32 ptype;
972976

973977
/* get the Rx desc from Rx queue based on 'next_to_clean' */
974978
rx_desc = &rx_q->rx[ntc];
@@ -989,16 +993,16 @@ static int idpf_rx_singleq_clean(struct idpf_rx_queue *rx_q, int budget)
989993
*/
990994
dma_rmb();
991995

992-
idpf_rx_singleq_extract_fields(rx_q, rx_desc, &fields);
996+
idpf_rx_singleq_extract_fields(rx_q, rx_desc, &fields, &ptype);
993997

994998
rx_buf = &rx_q->rx_buf[ntc];
995-
if (!libeth_rx_sync_for_cpu(rx_buf, fields.size))
999+
if (!libeth_rx_sync_for_cpu(rx_buf, fields.len))
9961000
goto skip_data;
9971001

9981002
if (skb)
999-
idpf_rx_add_frag(rx_buf, skb, fields.size);
1003+
idpf_rx_add_frag(rx_buf, skb, fields.len);
10001004
else
1001-
skb = idpf_rx_build_skb(rx_buf, fields.size);
1005+
skb = idpf_rx_build_skb(rx_buf, fields.len);
10021006

10031007
/* exit if we failed to retrieve a buffer */
10041008
if (!skb)
@@ -1033,8 +1037,7 @@ static int idpf_rx_singleq_clean(struct idpf_rx_queue *rx_q, int budget)
10331037
total_rx_bytes += skb->len;
10341038

10351039
/* protocol */
1036-
idpf_rx_singleq_process_skb_fields(rx_q, skb,
1037-
rx_desc, fields.rx_ptype);
1040+
idpf_rx_singleq_process_skb_fields(rx_q, skb, rx_desc, ptype);
10381041

10391042
/* send completed skb up the stack */
10401043
napi_gro_receive(rx_q->pp->p.napi, skb);

drivers/net/ethernet/intel/idpf/idpf_txrx.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,7 +2895,7 @@ idpf_rx_hash(const struct idpf_rx_queue *rxq, struct sk_buff *skb,
28952895
* skb->protocol must be set before this function is called
28962896
*/
28972897
static void idpf_rx_csum(struct idpf_rx_queue *rxq, struct sk_buff *skb,
2898-
struct idpf_rx_csum_decoded csum_bits,
2898+
struct libeth_rx_csum csum_bits,
28992899
struct libeth_rx_pt decoded)
29002900
{
29012901
bool ipv4, ipv6;
@@ -2923,7 +2923,7 @@ static void idpf_rx_csum(struct idpf_rx_queue *rxq, struct sk_buff *skb,
29232923
if (unlikely(csum_bits.l4e))
29242924
goto checksum_fail;
29252925

2926-
if (csum_bits.raw_csum_inv ||
2926+
if (!csum_bits.raw_csum_valid ||
29272927
decoded.inner_prot == LIBETH_RX_PT_INNER_SCTP) {
29282928
skb->ip_summed = CHECKSUM_UNNECESSARY;
29292929
return;
@@ -2946,10 +2946,10 @@ static void idpf_rx_csum(struct idpf_rx_queue *rxq, struct sk_buff *skb,
29462946
*
29472947
* Return: parsed checksum status.
29482948
**/
2949-
static struct idpf_rx_csum_decoded
2949+
static struct libeth_rx_csum
29502950
idpf_rx_splitq_extract_csum_bits(const struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc)
29512951
{
2952-
struct idpf_rx_csum_decoded csum = { };
2952+
struct libeth_rx_csum csum = { };
29532953
u8 qword0, qword1;
29542954

29552955
qword0 = rx_desc->status_err0_qw0;
@@ -2965,9 +2965,9 @@ idpf_rx_splitq_extract_csum_bits(const struct virtchnl2_rx_flex_desc_adv_nic_3 *
29652965
qword1);
29662966
csum.ipv6exadd = FIELD_GET(VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_IPV6EXADD_M,
29672967
qword0);
2968-
csum.raw_csum_inv =
2969-
le16_get_bits(rx_desc->ptype_err_fflags0,
2970-
VIRTCHNL2_RX_FLEX_DESC_ADV_RAW_CSUM_INV_M);
2968+
csum.raw_csum_valid =
2969+
!le16_get_bits(rx_desc->ptype_err_fflags0,
2970+
VIRTCHNL2_RX_FLEX_DESC_ADV_RAW_CSUM_INV_M);
29712971
csum.raw_csum = le16_to_cpu(rx_desc->misc.raw_cs);
29722972

29732973
return csum;
@@ -3058,7 +3058,7 @@ static int
30583058
idpf_rx_process_skb_fields(struct idpf_rx_queue *rxq, struct sk_buff *skb,
30593059
const struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc)
30603060
{
3061-
struct idpf_rx_csum_decoded csum_bits;
3061+
struct libeth_rx_csum csum_bits;
30623062
struct libeth_rx_pt decoded;
30633063
u16 rx_ptype;
30643064

drivers/net/ethernet/intel/idpf/idpf_txrx.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -213,25 +213,6 @@ enum idpf_tx_ctx_desc_eipt_offload {
213213
IDPF_TX_CTX_EXT_IP_IPV4 = 0x3
214214
};
215215

216-
/* Checksum offload bits decoded from the receive descriptor. */
217-
struct idpf_rx_csum_decoded {
218-
u32 l3l4p : 1;
219-
u32 ipe : 1;
220-
u32 eipe : 1;
221-
u32 eudpe : 1;
222-
u32 ipv6exadd : 1;
223-
u32 l4e : 1;
224-
u32 pprs : 1;
225-
u32 nat : 1;
226-
u32 raw_csum_inv : 1;
227-
u32 raw_csum : 16;
228-
};
229-
230-
struct idpf_rx_extracted {
231-
unsigned int size;
232-
u16 rx_ptype;
233-
};
234-
235216
#define IDPF_TX_COMPLQ_CLEAN_BUDGET 256
236217
#define IDPF_TX_MIN_PKT_LEN 17
237218
#define IDPF_TX_DESCS_FOR_SKB_DATA_PTR 1

include/net/libeth/rx.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,53 @@ struct libeth_rx_pt {
198198
enum xdp_rss_hash_type hash_type:16;
199199
};
200200

201+
/**
202+
* struct libeth_rx_csum - checksum offload bits decoded from the Rx descriptor
203+
* @l3l4p: detectable L3 and L4 integrity check is processed by the hardware
204+
* @ipe: IP checksum error
205+
* @eipe: external (outermost) IP header (only for tunels)
206+
* @eudpe: external (outermost) UDP checksum error (only for tunels)
207+
* @ipv6exadd: IPv6 header with extension headers
208+
* @l4e: L4 integrity error
209+
* @pprs: set for packets that skip checksum calculation in the HW pre parser
210+
* @nat: the packet is a UDP tunneled packet
211+
* @raw_csum_valid: set if raw checksum is valid
212+
* @pad: padding to naturally align raw_csum field
213+
* @raw_csum: raw checksum
214+
*/
215+
struct libeth_rx_csum {
216+
u32 l3l4p:1;
217+
u32 ipe:1;
218+
u32 eipe:1;
219+
u32 eudpe:1;
220+
u32 ipv6exadd:1;
221+
u32 l4e:1;
222+
u32 pprs:1;
223+
u32 nat:1;
224+
225+
u32 raw_csum_valid:1;
226+
u32 pad:7;
227+
u32 raw_csum:16;
228+
};
229+
230+
/**
231+
* struct libeth_rqe_info - receive queue element info
232+
* @len: packet length
233+
* @ptype: packet type based on types programmed into the device
234+
* @eop: whether it's the last fragment of the packet
235+
* @rxe: MAC errors: CRC, Alignment, Oversize, Undersizes, Length error
236+
* @vlan: C-VLAN or S-VLAN tag depending on the VLAN offload configuration
237+
*/
238+
struct libeth_rqe_info {
239+
u32 len;
240+
241+
u32 ptype:14;
242+
u32 eop:1;
243+
u32 rxe:1;
244+
245+
u32 vlan:16;
246+
};
247+
201248
void libeth_rx_pt_gen_hash_type(struct libeth_rx_pt *pt);
202249

203250
/**

0 commit comments

Comments
 (0)