Commit 93040ae5 authored by Somnath Kotur's avatar Somnath Kotur Committed by David S. Miller

be2net: Fix to trim skb for padded vlan packets to workaround an ASIC Bug

Fixed spelling error in a comment as pointed out by DaveM.
Also refactored existing code a bit to provide placeholders for another ASIC
Bug workaround that will be checked-in soon after this.
Signed-off-by: default avatarSomnath Kotur <somnath.kotur@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 525b8075
...@@ -573,6 +573,11 @@ static inline u8 is_udp_pkt(struct sk_buff *skb) ...@@ -573,6 +573,11 @@ static inline u8 is_udp_pkt(struct sk_buff *skb)
return val; return val;
} }
static inline bool is_ipv4_pkt(struct sk_buff *skb)
{
return skb->protocol == ntohs(ETH_P_IP) && ip_hdr(skb)->version == 4;
}
static inline void be_vf_eth_addr_generate(struct be_adapter *adapter, u8 *mac) static inline void be_vf_eth_addr_generate(struct be_adapter *adapter, u8 *mac)
{ {
u32 addr; u32 addr;
......
...@@ -577,6 +577,11 @@ static inline u16 be_get_tx_vlan_tag(struct be_adapter *adapter, ...@@ -577,6 +577,11 @@ static inline u16 be_get_tx_vlan_tag(struct be_adapter *adapter,
return vlan_tag; return vlan_tag;
} }
static int be_vlan_tag_chk(struct be_adapter *adapter, struct sk_buff *skb)
{
return vlan_tx_tag_present(skb) || adapter->pvid;
}
static void wrb_fill_hdr(struct be_adapter *adapter, struct be_eth_hdr_wrb *hdr, static void wrb_fill_hdr(struct be_adapter *adapter, struct be_eth_hdr_wrb *hdr,
struct sk_buff *skb, u32 wrb_cnt, u32 len) struct sk_buff *skb, u32 wrb_cnt, u32 len)
{ {
...@@ -704,33 +709,56 @@ static int make_tx_wrbs(struct be_adapter *adapter, struct be_queue_info *txq, ...@@ -704,33 +709,56 @@ static int make_tx_wrbs(struct be_adapter *adapter, struct be_queue_info *txq,
return 0; return 0;
} }
static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter,
struct sk_buff *skb)
{
u16 vlan_tag = 0;
skb = skb_share_check(skb, GFP_ATOMIC);
if (unlikely(!skb))
return skb;
if (vlan_tx_tag_present(skb)) {
vlan_tag = be_get_tx_vlan_tag(adapter, skb);
__vlan_put_tag(skb, vlan_tag);
skb->vlan_tci = 0;
}
return skb;
}
static netdev_tx_t be_xmit(struct sk_buff *skb, static netdev_tx_t be_xmit(struct sk_buff *skb,
struct net_device *netdev) struct net_device *netdev)
{ {
struct be_adapter *adapter = netdev_priv(netdev); struct be_adapter *adapter = netdev_priv(netdev);
struct be_tx_obj *txo = &adapter->tx_obj[skb_get_queue_mapping(skb)]; struct be_tx_obj *txo = &adapter->tx_obj[skb_get_queue_mapping(skb)];
struct be_queue_info *txq = &txo->q; struct be_queue_info *txq = &txo->q;
struct iphdr *ip = NULL;
u32 wrb_cnt = 0, copied = 0; u32 wrb_cnt = 0, copied = 0;
u32 start = txq->head; u32 start = txq->head, eth_hdr_len;
bool dummy_wrb, stopped = false; bool dummy_wrb, stopped = false;
/* For vlan tagged pkts, BE eth_hdr_len = ntohs(skb->protocol) == ETH_P_8021Q ?
* 1) calculates checksum even when CSO is not requested VLAN_ETH_HLEN : ETH_HLEN;
* 2) calculates checksum wrongly for padded pkt less than
* 60 bytes long. /* HW has a bug which considers padding bytes as legal
* As a workaround disable TX vlan offloading in such cases. * and modifies the IPv4 hdr's 'tot_len' field
*/ */
if (vlan_tx_tag_present(skb) && if (skb->len <= 60 && be_vlan_tag_chk(adapter, skb) &&
(skb->ip_summed != CHECKSUM_PARTIAL || skb->len <= 60)) { is_ipv4_pkt(skb)) {
skb = skb_share_check(skb, GFP_ATOMIC); ip = (struct iphdr *)ip_hdr(skb);
if (unlikely(!skb)) pskb_trim(skb, eth_hdr_len + ntohs(ip->tot_len));
goto tx_drop; }
skb = __vlan_put_tag(skb, be_get_tx_vlan_tag(adapter, skb)); /* HW has a bug wherein it will calculate CSUM for VLAN
* pkts even though it is disabled.
* Manually insert VLAN in pkt.
*/
if (skb->ip_summed != CHECKSUM_PARTIAL &&
be_vlan_tag_chk(adapter, skb)) {
skb = be_insert_vlan_in_pkt(adapter, skb);
if (unlikely(!skb)) if (unlikely(!skb))
goto tx_drop; goto tx_drop;
skb->vlan_tci = 0;
} }
wrb_cnt = wrb_cnt_for_skb(adapter, skb, &dummy_wrb); wrb_cnt = wrb_cnt_for_skb(adapter, skb, &dummy_wrb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment