Skip to content

Commit 24cd23d

Browse files
Alexander Duyckdavem330
authored andcommitted
igb: use new eth_get_headlen interface
Update igb to drop the igb_get_headlen function in favor of eth_get_headlen. Signed-off-by: Alexander Duyck <[email protected]> Acked-by: Jeff Kirsher <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 56193d1 commit 24cd23d

File tree

1 file changed

+1
-108
lines changed

1 file changed

+1
-108
lines changed

drivers/net/ethernet/intel/igb/igb_main.c

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -6768,113 +6768,6 @@ static bool igb_is_non_eop(struct igb_ring *rx_ring,
67686768
return true;
67696769
}
67706770

6771-
/**
6772-
* igb_get_headlen - determine size of header for LRO/GRO
6773-
* @data: pointer to the start of the headers
6774-
* @max_len: total length of section to find headers in
6775-
*
6776-
* This function is meant to determine the length of headers that will
6777-
* be recognized by hardware for LRO, and GRO offloads. The main
6778-
* motivation of doing this is to only perform one pull for IPv4 TCP
6779-
* packets so that we can do basic things like calculating the gso_size
6780-
* based on the average data per packet.
6781-
**/
6782-
static unsigned int igb_get_headlen(unsigned char *data,
6783-
unsigned int max_len)
6784-
{
6785-
union {
6786-
unsigned char *network;
6787-
/* l2 headers */
6788-
struct ethhdr *eth;
6789-
struct vlan_hdr *vlan;
6790-
/* l3 headers */
6791-
struct iphdr *ipv4;
6792-
struct ipv6hdr *ipv6;
6793-
} hdr;
6794-
__be16 protocol;
6795-
u8 nexthdr = 0; /* default to not TCP */
6796-
u8 hlen;
6797-
6798-
/* this should never happen, but better safe than sorry */
6799-
if (max_len < ETH_HLEN)
6800-
return max_len;
6801-
6802-
/* initialize network frame pointer */
6803-
hdr.network = data;
6804-
6805-
/* set first protocol and move network header forward */
6806-
protocol = hdr.eth->h_proto;
6807-
hdr.network += ETH_HLEN;
6808-
6809-
/* handle any vlan tag if present */
6810-
if (protocol == htons(ETH_P_8021Q)) {
6811-
if ((hdr.network - data) > (max_len - VLAN_HLEN))
6812-
return max_len;
6813-
6814-
protocol = hdr.vlan->h_vlan_encapsulated_proto;
6815-
hdr.network += VLAN_HLEN;
6816-
}
6817-
6818-
/* handle L3 protocols */
6819-
if (protocol == htons(ETH_P_IP)) {
6820-
if ((hdr.network - data) > (max_len - sizeof(struct iphdr)))
6821-
return max_len;
6822-
6823-
/* access ihl as a u8 to avoid unaligned access on ia64 */
6824-
hlen = (hdr.network[0] & 0x0F) << 2;
6825-
6826-
/* verify hlen meets minimum size requirements */
6827-
if (hlen < sizeof(struct iphdr))
6828-
return hdr.network - data;
6829-
6830-
/* record next protocol if header is present */
6831-
if (!(hdr.ipv4->frag_off & htons(IP_OFFSET)))
6832-
nexthdr = hdr.ipv4->protocol;
6833-
} else if (protocol == htons(ETH_P_IPV6)) {
6834-
if ((hdr.network - data) > (max_len - sizeof(struct ipv6hdr)))
6835-
return max_len;
6836-
6837-
/* record next protocol */
6838-
nexthdr = hdr.ipv6->nexthdr;
6839-
hlen = sizeof(struct ipv6hdr);
6840-
} else {
6841-
return hdr.network - data;
6842-
}
6843-
6844-
/* relocate pointer to start of L4 header */
6845-
hdr.network += hlen;
6846-
6847-
/* finally sort out TCP */
6848-
if (nexthdr == IPPROTO_TCP) {
6849-
if ((hdr.network - data) > (max_len - sizeof(struct tcphdr)))
6850-
return max_len;
6851-
6852-
/* access doff as a u8 to avoid unaligned access on ia64 */
6853-
hlen = (hdr.network[12] & 0xF0) >> 2;
6854-
6855-
/* verify hlen meets minimum size requirements */
6856-
if (hlen < sizeof(struct tcphdr))
6857-
return hdr.network - data;
6858-
6859-
hdr.network += hlen;
6860-
} else if (nexthdr == IPPROTO_UDP) {
6861-
if ((hdr.network - data) > (max_len - sizeof(struct udphdr)))
6862-
return max_len;
6863-
6864-
hdr.network += sizeof(struct udphdr);
6865-
}
6866-
6867-
/* If everything has gone correctly hdr.network should be the
6868-
* data section of the packet and will be the end of the header.
6869-
* If not then it probably represents the end of the last recognized
6870-
* header.
6871-
*/
6872-
if ((hdr.network - data) < max_len)
6873-
return hdr.network - data;
6874-
else
6875-
return max_len;
6876-
}
6877-
68786771
/**
68796772
* igb_pull_tail - igb specific version of skb_pull_tail
68806773
* @rx_ring: rx descriptor ring packet is being transacted on
@@ -6919,7 +6812,7 @@ static void igb_pull_tail(struct igb_ring *rx_ring,
69196812
/* we need the header to contain the greater of either ETH_HLEN or
69206813
* 60 bytes if the skb->len is less than 60 for skb_pad.
69216814
*/
6922-
pull_len = igb_get_headlen(va, IGB_RX_HDR_LEN);
6815+
pull_len = eth_get_headlen(va, IGB_RX_HDR_LEN);
69236816

69246817
/* align pull length to size of long to optimize memcpy performance */
69256818
skb_copy_to_linear_data(skb, va, ALIGN(pull_len, sizeof(long)));

0 commit comments

Comments
 (0)