Commit 57569d0e authored by Rajesh Borundia's avatar Rajesh Borundia Committed by David S. Miller

netxen: add vlan LRO support

o To support vlan lro, driver need to program ip address in device.
o Same ip addresses need to be program after fw recovery, so sotre them
  in list.
o In case of vlan packet, include vlan header length while
calculating ip and tcp headers.
Signed-off-by: default avatarRajesh Borundia <rajesh.borundia@qlogic.com>
Signed-off-by: default avatarAmit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2ae40ee9
...@@ -940,6 +940,11 @@ typedef struct nx_mac_list_s { ...@@ -940,6 +940,11 @@ typedef struct nx_mac_list_s {
uint8_t mac_addr[ETH_ALEN+2]; uint8_t mac_addr[ETH_ALEN+2];
} nx_mac_list_t; } nx_mac_list_t;
struct nx_vlan_ip_list {
struct list_head list;
u32 ip_addr;
};
/* /*
* Interrupt coalescing defaults. The defaults are for 1500 MTU. It is * Interrupt coalescing defaults. The defaults are for 1500 MTU. It is
* adjusted based on configured MTU. * adjusted based on configured MTU.
...@@ -1165,6 +1170,7 @@ struct netxen_adapter { ...@@ -1165,6 +1170,7 @@ struct netxen_adapter {
struct net_device *netdev; struct net_device *netdev;
struct pci_dev *pdev; struct pci_dev *pdev;
struct list_head mac_list; struct list_head mac_list;
struct list_head vlan_ip_list;
spinlock_t tx_clean_lock; spinlock_t tx_clean_lock;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/if_vlan.h>
#include "netxen_nic.h" #include "netxen_nic.h"
#include "netxen_nic_hw.h" #include "netxen_nic_hw.h"
...@@ -1619,6 +1620,7 @@ netxen_process_lro(struct netxen_adapter *adapter, ...@@ -1619,6 +1620,7 @@ netxen_process_lro(struct netxen_adapter *adapter,
int index; int index;
u16 lro_length, length, data_offset; u16 lro_length, length, data_offset;
u32 seq_number; u32 seq_number;
u8 vhdr_len;
if (unlikely(ring > adapter->max_rds_rings)) if (unlikely(ring > adapter->max_rds_rings))
return NULL; return NULL;
...@@ -1652,8 +1654,10 @@ netxen_process_lro(struct netxen_adapter *adapter, ...@@ -1652,8 +1654,10 @@ netxen_process_lro(struct netxen_adapter *adapter,
skb_pull(skb, l2_hdr_offset); skb_pull(skb, l2_hdr_offset);
skb->protocol = eth_type_trans(skb, netdev); skb->protocol = eth_type_trans(skb, netdev);
iph = (struct iphdr *)skb->data; if (skb->protocol == htons(ETH_P_8021Q))
th = (struct tcphdr *)(skb->data + (iph->ihl << 2)); vhdr_len = VLAN_HLEN;
iph = (struct iphdr *)(skb->data + vhdr_len);
th = (struct tcphdr *)((skb->data + vhdr_len) + (iph->ihl << 2));
length = (iph->ihl << 2) + (th->doff << 2) + lro_length; length = (iph->ihl << 2) + (th->doff << 2) + lro_length;
iph->tot_len = htons(length); iph->tot_len = htons(length);
......
...@@ -91,7 +91,8 @@ static irqreturn_t netxen_intr(int irq, void *data); ...@@ -91,7 +91,8 @@ static irqreturn_t netxen_intr(int irq, void *data);
static irqreturn_t netxen_msi_intr(int irq, void *data); static irqreturn_t netxen_msi_intr(int irq, void *data);
static irqreturn_t netxen_msix_intr(int irq, void *data); static irqreturn_t netxen_msix_intr(int irq, void *data);
static void netxen_config_indev_addr(struct net_device *dev, unsigned long); static void netxen_free_vlan_ip_list(struct netxen_adapter *);
static void netxen_restore_indev_addr(struct net_device *dev, unsigned long);
static struct rtnl_link_stats64 *netxen_nic_get_stats(struct net_device *dev, static struct rtnl_link_stats64 *netxen_nic_get_stats(struct net_device *dev,
struct rtnl_link_stats64 *stats); struct rtnl_link_stats64 *stats);
static int netxen_nic_set_mac(struct net_device *netdev, void *p); static int netxen_nic_set_mac(struct net_device *netdev, void *p);
...@@ -1359,6 +1360,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1359,6 +1360,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
spin_lock_init(&adapter->tx_clean_lock); spin_lock_init(&adapter->tx_clean_lock);
INIT_LIST_HEAD(&adapter->mac_list); INIT_LIST_HEAD(&adapter->mac_list);
INIT_LIST_HEAD(&adapter->vlan_ip_list);
err = netxen_setup_pci_map(adapter); err = netxen_setup_pci_map(adapter);
if (err) if (err)
...@@ -1481,6 +1483,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) ...@@ -1481,6 +1483,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
cancel_work_sync(&adapter->tx_timeout_task); cancel_work_sync(&adapter->tx_timeout_task);
netxen_free_vlan_ip_list(adapter);
netxen_nic_detach(adapter); netxen_nic_detach(adapter);
nx_decr_dev_ref_cnt(adapter); nx_decr_dev_ref_cnt(adapter);
...@@ -1563,7 +1566,7 @@ static int netxen_nic_attach_func(struct pci_dev *pdev) ...@@ -1563,7 +1566,7 @@ static int netxen_nic_attach_func(struct pci_dev *pdev)
if (err) if (err)
goto err_out_detach; goto err_out_detach;
netxen_config_indev_addr(netdev, NETDEV_UP); netxen_restore_indev_addr(netdev, NETDEV_UP);
} }
netif_device_attach(netdev); netif_device_attach(netdev);
...@@ -2374,7 +2377,7 @@ netxen_attach_work(struct work_struct *work) ...@@ -2374,7 +2377,7 @@ netxen_attach_work(struct work_struct *work)
goto done; goto done;
} }
netxen_config_indev_addr(netdev, NETDEV_UP); netxen_restore_indev_addr(netdev, NETDEV_UP);
} }
netif_device_attach(netdev); netif_device_attach(netdev);
...@@ -2848,10 +2851,70 @@ netxen_destip_supported(struct netxen_adapter *adapter) ...@@ -2848,10 +2851,70 @@ netxen_destip_supported(struct netxen_adapter *adapter)
} }
static void static void
netxen_config_indev_addr(struct net_device *dev, unsigned long event) netxen_free_vlan_ip_list(struct netxen_adapter *adapter)
{
struct nx_vlan_ip_list *cur;
struct list_head *head = &adapter->vlan_ip_list;
while (!list_empty(head)) {
cur = list_entry(head->next, struct nx_vlan_ip_list, list);
netxen_config_ipaddr(adapter, cur->ip_addr, NX_IP_DOWN);
list_del(&cur->list);
kfree(cur);
}
}
static void
netxen_list_config_vlan_ip(struct netxen_adapter *adapter,
struct in_ifaddr *ifa, unsigned long event)
{
struct net_device *dev;
struct nx_vlan_ip_list *cur, *tmp_cur;
struct list_head *head;
dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL;
if (dev == NULL)
return;
if (!is_vlan_dev(dev))
return;
switch (event) {
case NX_IP_UP:
list_for_each(head, &adapter->vlan_ip_list) {
cur = list_entry(head, struct nx_vlan_ip_list, list);
if (cur->ip_addr == ifa->ifa_address)
return;
}
cur = kzalloc(sizeof(struct nx_vlan_ip_list), GFP_ATOMIC);
if (cur == NULL) {
printk(KERN_ERR "%s: failed to add vlan ip to list\n",
adapter->netdev->name);
return;
}
cur->ip_addr = ifa->ifa_address;
list_add_tail(&cur->list, &adapter->vlan_ip_list);
break;
case NX_IP_DOWN:
list_for_each_entry_safe(cur, tmp_cur,
&adapter->vlan_ip_list, list) {
if (cur->ip_addr == ifa->ifa_address) {
list_del(&cur->list);
kfree(cur);
break;
}
}
}
}
static void
netxen_config_indev_addr(struct netxen_adapter *adapter,
struct net_device *dev, unsigned long event)
{ {
struct in_device *indev; struct in_device *indev;
struct netxen_adapter *adapter = netdev_priv(dev);
if (!netxen_destip_supported(adapter)) if (!netxen_destip_supported(adapter))
return; return;
...@@ -2865,10 +2928,12 @@ netxen_config_indev_addr(struct net_device *dev, unsigned long event) ...@@ -2865,10 +2928,12 @@ netxen_config_indev_addr(struct net_device *dev, unsigned long event)
case NETDEV_UP: case NETDEV_UP:
netxen_config_ipaddr(adapter, netxen_config_ipaddr(adapter,
ifa->ifa_address, NX_IP_UP); ifa->ifa_address, NX_IP_UP);
netxen_list_config_vlan_ip(adapter, ifa, NX_IP_UP);
break; break;
case NETDEV_DOWN: case NETDEV_DOWN:
netxen_config_ipaddr(adapter, netxen_config_ipaddr(adapter,
ifa->ifa_address, NX_IP_DOWN); ifa->ifa_address, NX_IP_DOWN);
netxen_list_config_vlan_ip(adapter, ifa, NX_IP_DOWN);
break; break;
default: default:
break; break;
...@@ -2878,11 +2943,28 @@ netxen_config_indev_addr(struct net_device *dev, unsigned long event) ...@@ -2878,11 +2943,28 @@ netxen_config_indev_addr(struct net_device *dev, unsigned long event)
in_dev_put(indev); in_dev_put(indev);
} }
static void
netxen_restore_indev_addr(struct net_device *netdev, unsigned long event)
{
struct netxen_adapter *adapter = netdev_priv(netdev);
struct nx_vlan_ip_list *pos, *tmp_pos;
unsigned long ip_event;
ip_event = (event == NETDEV_UP) ? NX_IP_UP : NX_IP_DOWN;
netxen_config_indev_addr(adapter, netdev, event);
list_for_each_entry_safe(pos, tmp_pos, &adapter->vlan_ip_list, list) {
netxen_config_ipaddr(adapter, pos->ip_addr, ip_event);
}
}
static int netxen_netdev_event(struct notifier_block *this, static int netxen_netdev_event(struct notifier_block *this,
unsigned long event, void *ptr) unsigned long event, void *ptr)
{ {
struct netxen_adapter *adapter; struct netxen_adapter *adapter;
struct net_device *dev = (struct net_device *)ptr; struct net_device *dev = (struct net_device *)ptr;
struct net_device *orig_dev = dev;
recheck: recheck:
if (dev == NULL) if (dev == NULL)
...@@ -2904,7 +2986,7 @@ static int netxen_netdev_event(struct notifier_block *this, ...@@ -2904,7 +2986,7 @@ static int netxen_netdev_event(struct notifier_block *this,
if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
goto done; goto done;
netxen_config_indev_addr(dev, event); netxen_config_indev_addr(adapter, orig_dev, event);
done: done:
return NOTIFY_DONE; return NOTIFY_DONE;
} }
...@@ -2921,7 +3003,7 @@ netxen_inetaddr_event(struct notifier_block *this, ...@@ -2921,7 +3003,7 @@ netxen_inetaddr_event(struct notifier_block *this,
dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL; dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL;
recheck: recheck:
if (dev == NULL || !netif_running(dev)) if (dev == NULL)
goto done; goto done;
if (dev->priv_flags & IFF_802_1Q_VLAN) { if (dev->priv_flags & IFF_802_1Q_VLAN) {
...@@ -2943,9 +3025,11 @@ netxen_inetaddr_event(struct notifier_block *this, ...@@ -2943,9 +3025,11 @@ netxen_inetaddr_event(struct notifier_block *this,
switch (event) { switch (event) {
case NETDEV_UP: case NETDEV_UP:
netxen_config_ipaddr(adapter, ifa->ifa_address, NX_IP_UP); netxen_config_ipaddr(adapter, ifa->ifa_address, NX_IP_UP);
netxen_list_config_vlan_ip(adapter, ifa, NX_IP_UP);
break; break;
case NETDEV_DOWN: case NETDEV_DOWN:
netxen_config_ipaddr(adapter, ifa->ifa_address, NX_IP_DOWN); netxen_config_ipaddr(adapter, ifa->ifa_address, NX_IP_DOWN);
netxen_list_config_vlan_ip(adapter, ifa, NX_IP_DOWN);
break; break;
default: default:
break; break;
...@@ -2964,7 +3048,10 @@ static struct notifier_block netxen_inetaddr_cb = { ...@@ -2964,7 +3048,10 @@ static struct notifier_block netxen_inetaddr_cb = {
}; };
#else #else
static void static void
netxen_config_indev_addr(struct net_device *dev, unsigned long event) netxen_restore_indev_addr(struct net_device *dev, unsigned long event)
{ }
static void
netxen_free_vlan_ip_list(struct netxen_adapter *adapter)
{ } { }
#endif #endif
......
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