Skip to content

Commit 339379a

Browse files
Huazhong Tandavem330
authored andcommitted
net: hns: use eth_get_headlen interface instead of hns_nic_get_headlen
Update hns to drop the hns_nic_get_headlen function in favour of eth_get_headlen, and hence also removes now redundant hns_nic_get_headlen. Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: Salil Mehta <salil.mehta@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b1ccd4c commit 339379a

File tree

1 file changed

+1
-102
lines changed

1 file changed

+1
-102
lines changed

drivers/net/ethernet/hisilicon/hns/hns_enet.c

Lines changed: 1 addition & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -406,107 +406,6 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
406406
return NETDEV_TX_BUSY;
407407
}
408408

409-
/**
410-
* hns_nic_get_headlen - determine size of header for RSC/LRO/GRO/FCOE
411-
* @data: pointer to the start of the headers
412-
* @max: total length of section to find headers in
413-
*
414-
* This function is meant to determine the length of headers that will
415-
* be recognized by hardware for LRO, GRO, and RSC offloads. The main
416-
* motivation of doing this is to only perform one pull for IPv4 TCP
417-
* packets so that we can do basic things like calculating the gso_size
418-
* based on the average data per packet.
419-
**/
420-
static unsigned int hns_nic_get_headlen(unsigned char *data, u32 flag,
421-
unsigned int max_size)
422-
{
423-
unsigned char *network;
424-
u8 hlen;
425-
426-
/* this should never happen, but better safe than sorry */
427-
if (max_size < ETH_HLEN)
428-
return max_size;
429-
430-
/* initialize network frame pointer */
431-
network = data;
432-
433-
/* set first protocol and move network header forward */
434-
network += ETH_HLEN;
435-
436-
/* handle any vlan tag if present */
437-
if (hnae_get_field(flag, HNS_RXD_VLAN_M, HNS_RXD_VLAN_S)
438-
== HNS_RX_FLAG_VLAN_PRESENT) {
439-
if ((typeof(max_size))(network - data) > (max_size - VLAN_HLEN))
440-
return max_size;
441-
442-
network += VLAN_HLEN;
443-
}
444-
445-
/* handle L3 protocols */
446-
if (hnae_get_field(flag, HNS_RXD_L3ID_M, HNS_RXD_L3ID_S)
447-
== HNS_RX_FLAG_L3ID_IPV4) {
448-
if ((typeof(max_size))(network - data) >
449-
(max_size - sizeof(struct iphdr)))
450-
return max_size;
451-
452-
/* access ihl as a u8 to avoid unaligned access on ia64 */
453-
hlen = (network[0] & 0x0F) << 2;
454-
455-
/* verify hlen meets minimum size requirements */
456-
if (hlen < sizeof(struct iphdr))
457-
return network - data;
458-
459-
/* record next protocol if header is present */
460-
} else if (hnae_get_field(flag, HNS_RXD_L3ID_M, HNS_RXD_L3ID_S)
461-
== HNS_RX_FLAG_L3ID_IPV6) {
462-
if ((typeof(max_size))(network - data) >
463-
(max_size - sizeof(struct ipv6hdr)))
464-
return max_size;
465-
466-
/* record next protocol */
467-
hlen = sizeof(struct ipv6hdr);
468-
} else {
469-
return network - data;
470-
}
471-
472-
/* relocate pointer to start of L4 header */
473-
network += hlen;
474-
475-
/* finally sort out TCP/UDP */
476-
if (hnae_get_field(flag, HNS_RXD_L4ID_M, HNS_RXD_L4ID_S)
477-
== HNS_RX_FLAG_L4ID_TCP) {
478-
if ((typeof(max_size))(network - data) >
479-
(max_size - sizeof(struct tcphdr)))
480-
return max_size;
481-
482-
/* access doff as a u8 to avoid unaligned access on ia64 */
483-
hlen = (network[12] & 0xF0) >> 2;
484-
485-
/* verify hlen meets minimum size requirements */
486-
if (hlen < sizeof(struct tcphdr))
487-
return network - data;
488-
489-
network += hlen;
490-
} else if (hnae_get_field(flag, HNS_RXD_L4ID_M, HNS_RXD_L4ID_S)
491-
== HNS_RX_FLAG_L4ID_UDP) {
492-
if ((typeof(max_size))(network - data) >
493-
(max_size - sizeof(struct udphdr)))
494-
return max_size;
495-
496-
network += sizeof(struct udphdr);
497-
}
498-
499-
/* If everything has gone correctly network should be the
500-
* data section of the packet and will be the end of the header.
501-
* If not then it probably represents the end of the last recognized
502-
* header.
503-
*/
504-
if ((typeof(max_size))(network - data) < max_size)
505-
return network - data;
506-
else
507-
return max_size;
508-
}
509-
510409
static void hns_nic_reuse_page(struct sk_buff *skb, int i,
511410
struct hnae_ring *ring, int pull_len,
512411
struct hnae_desc_cb *desc_cb)
@@ -696,7 +595,7 @@ static int hns_nic_poll_rx_skb(struct hns_nic_ring_data *ring_data,
696595
} else {
697596
ring->stats.seg_pkt_cnt++;
698597

699-
pull_len = hns_nic_get_headlen(va, bnum_flag, HNS_RX_HEAD_SIZE);
598+
pull_len = eth_get_headlen(va, HNS_RX_HEAD_SIZE);
700599
memcpy(__skb_put(skb, pull_len), va,
701600
ALIGN(pull_len, sizeof(long)));
702601

0 commit comments

Comments
 (0)