34 #include <linux/module.h>
36 #include <linux/netdevice.h>
38 #include <linux/ethtool.h>
39 #include <linux/mii.h>
40 #include <linux/if_vlan.h>
45 #include <linux/if_arp.h>
47 #include <linux/slab.h>
50 #include <asm/byteorder.h>
94 static bool limit_maxrdreqsz;
96 MODULE_PARM_DESC(limit_maxrdreqsz,
"Limit max read request size to 256 Bytes");
103 static unsigned int ee_flsh_adapter;
104 static unsigned int sysfs_nonidx_addr;
105 static unsigned int sysfs_idx_addr;
115 static int nes_inetaddr_event(
struct notifier_block *,
unsigned long,
void *);
116 static int nes_net_event(
struct notifier_block *,
unsigned long,
void *);
117 static int nes_notifiers_registered;
121 .notifier_call = nes_inetaddr_event
125 .notifier_call = nes_net_event
134 struct in_ifaddr *ifa =
ptr;
139 unsigned int is_bonded;
142 &ifa->ifa_address, &ifa->ifa_mask);
145 nesdev, nesdev->
netdev[0]->name);
146 netdev = nesdev->
netdev[0];
147 nesvnic = netdev_priv(netdev);
148 is_bonded = netif_is_bond_slave(netdev) &&
149 (netdev->
master == event_netdev);
150 if ((netdev == event_netdev) || is_bonded) {
153 " RDMA is not enabled.\n",
161 nes_write_indexed(nesdev,
184 ((
struct in_device *)netdev->
master->ip_ptr)->ifa_list->ifa_address;
188 nes_write_indexed(nesdev,
212 unsigned long event,
void *ptr)
223 netdev = nesdev->
netdev[0];
224 nesvnic = netdev_priv(netdev);
225 if (netdev == neigh->
dev) {
258 nesqp = to_nesqp(ibqp);
276 nesqp->
hwqp.q2_vbase, nesqp->
hwqp.q2_pbase);
279 spin_unlock_irqrestore(&nesadapter->
pbl_lock, flags);
285 nesqp->
hwqp.sq_vbase, nesqp->
hwqp.sq_pbase);
307 nesqp = to_nesqp(ibqp);
321 if (cqp_request ==
NULL) {
329 cqp_wqe = &cqp_request->
cqp_wqe;
331 nes_fill_init_cqp_wqe(cqp_wqe, nesdev);
352 struct nes_vnic *nesvnic = to_nesvnic(device);
366 static void nes_print_macaddr(
struct net_device *netdev)
393 if (int_mask & 0x80000000) {
397 if (int_stat&int_req) {
402 if (((int_stat & int_req) &
NES_INT_TIMER) == NES_INT_TIMER) {
409 if ((((int_stat & int_req) &
NES_INT_INTF) == NES_INT_INTF) &&
463 printk(
KERN_ERR PFX
"Unable to enable PCI device. (%s)\n", pci_name(pcidev));
485 printk(
KERN_ERR PFX
"Unable to request regions. (%s)\n", pci_name(pcidev));
495 ret = pci_set_consistent_dma_mask(pcidev,
DMA_BIT_MASK(64));
497 printk(
KERN_ERR PFX
"64b DMA consistent mask configuration failed\n");
506 ret = pci_set_consistent_dma_mask(pcidev,
DMA_BIT_MASK(32));
508 printk(
KERN_ERR PFX
"32b DMA consistent mask configuration failed\n");
518 printk(
KERN_ERR PFX
"%s: Unable to alloc hardware struct\n", pci_name(pcidev));
525 pci_set_drvdata(pcidev, nesdev);
527 pci_read_config_byte(pcidev, 0x0008, &hw_rev);
535 if (mmio_regs ==
NULL) {
540 nesdev->
regs = mmio_regs;
547 if (!pci_enable_msi(nesdev->
pcidev)) {
598 if ((limit_maxrdreqsz ||
661 pci_name(pcidev), pcidev->
irq);
667 if (nes_notifiers_registered == 0) {
671 nes_notifiers_registered++;
682 printk(
KERN_ERR PFX
"Unable to register netdev, ret = %d\n", ret);
687 nes_print_macaddr(netdev);
692 printk(
KERN_INFO PFX
"%s: NetEffect RNIC driver successfully loaded.\n",
709 nes_notifiers_registered--;
710 if (nes_notifiers_registered == 0) {
754 struct nes_device *nesdev = pci_get_drvdata(pcidev);
756 int netdev_index = 0;
760 netdev = nesdev->
netdev[netdev_index];
762 netif_stop_queue(netdev);
772 nes_notifiers_registered--;
773 if (nes_notifiers_registered == 0) {
786 spin_unlock_irqrestore(&nesdev->
nesadapter->phy_lock, flags);
789 spin_unlock_irqrestore(&nesdev->
nesadapter->phy_lock, flags);
805 pci_set_drvdata(pcidev,
NULL);
811 .id_table = nes_pci_table,
818 unsigned int devfn = 0xffffffff;
819 unsigned char bus_number = 0xff;
824 if (i == ee_flsh_adapter) {
825 devfn = nesdev->
pcidev->devfn;
826 bus_number = nesdev->
pcidev->bus->number;
836 const char *buf,
size_t count)
838 char *
p = (
char *)buf;
846 u32 eeprom_cmd = 0xdead;
851 if (i == ee_flsh_adapter) {
861 const char *buf,
size_t count)
863 char *
p = (
char *)buf;
868 if (p[1] ==
'x' || p[1] ==
'X' || p[0] ==
'x' || p[0] ==
'X') {
871 if (i == ee_flsh_adapter) {
888 if (i == ee_flsh_adapter) {
899 const char *buf,
size_t count)
901 char *p = (
char *)buf;
906 if (p[1] ==
'x' || p[1] ==
'X' || p[0] ==
'x' || p[0] ==
'X') {
909 if (i == ee_flsh_adapter) {
921 u32 flash_cmd = 0xdead;
926 if (i == ee_flsh_adapter) {
937 const char *buf,
size_t count)
939 char *p = (
char *)buf;
944 if (p[1] ==
'x' || p[1] ==
'X' || p[0] ==
'x' || p[0] ==
'X') {
947 if (i == ee_flsh_adapter) {
959 u32 flash_data = 0xdead;
964 if (i == ee_flsh_adapter) {
975 const char *buf,
size_t count)
977 char *p = (
char *)buf;
982 if (p[1] ==
'x' || p[1] ==
'X' || p[0] ==
'x' || p[0] ==
'X') {
985 if (i == ee_flsh_adapter) {
1001 const char *buf,
size_t count)
1003 char *p = (
char *)buf;
1005 if (p[1] ==
'x' || p[1] ==
'X' || p[0] ==
'x' || p[0] ==
'X')
1013 u32 nonidx_data = 0xdead;
1018 if (i == ee_flsh_adapter) {
1019 nonidx_data = nes_read32(nesdev->
regs + sysfs_nonidx_addr);
1029 const char *buf,
size_t count)
1031 char *p = (
char *)buf;
1036 if (p[1] ==
'x' || p[1] ==
'X' || p[0] ==
'x' || p[0] ==
'X') {
1039 if (i == ee_flsh_adapter) {
1040 nes_write32(nesdev->
regs + sysfs_nonidx_addr, val);
1055 const char *buf,
size_t count)
1057 char *p = (
char *)buf;
1059 if (p[1] ==
'x' || p[1] ==
'X' || p[0] ==
'x' || p[0] ==
'X')
1067 u32 idx_data = 0xdead;
1072 if (i == ee_flsh_adapter) {
1073 idx_data = nes_read_indexed(nesdev, sysfs_idx_addr);
1083 const char *buf,
size_t count)
1085 char *p = (
char *)buf;
1090 if (p[1] ==
'x' || p[1] ==
'X' || p[0] ==
'x' || p[0] ==
'X') {
1093 if (i == ee_flsh_adapter) {
1094 nes_write_indexed(nesdev, sysfs_idx_addr, val);
1109 u32 wqm_quanta_value = 0xdead;
1114 if (i == ee_flsh_adapter) {
1115 wqm_quanta_value = nesdev->
nesadapter->wqm_quanta;
1129 const char *buf,
size_t count)
1131 unsigned long wqm_quanta_value;
1136 if (kstrtoul(buf, 0, &wqm_quanta_value) < 0)
1140 if (i == ee_flsh_adapter) {
1141 nesdev->
nesadapter->wqm_quanta = wqm_quanta_value;
1142 wqm_config1 = nes_read_indexed(nesdev,
1145 ((wqm_quanta_value << 1) |
1146 (wqm_config1 & 0x00000001)));
1155 nes_show_adapter, nes_store_adapter);
1157 nes_show_ee_cmd, nes_store_ee_cmd);
1159 nes_show_ee_data, nes_store_ee_data);
1161 nes_show_flash_cmd, nes_store_flash_cmd);
1163 nes_show_flash_data, nes_store_flash_data);
1165 nes_show_nonidx_addr, nes_store_nonidx_addr);
1167 nes_show_nonidx_data, nes_store_nonidx_data);
1169 nes_show_idx_addr, nes_store_idx_addr);
1171 nes_show_idx_data, nes_store_idx_data);
1173 nes_show_wqm_quanta, nes_store_wqm_quanta);
1175 static int nes_create_driver_sysfs(
struct pci_driver *drv)
1191 static void nes_remove_driver_sysfs(
struct pci_driver *drv)
1208 static int __init nes_init_module(
void)
1218 retval = pci_register_driver(&nes_pci_driver);
1220 retval1 = nes_create_driver_sysfs(&nes_pci_driver);
1231 static void __exit nes_exit_module(
void)
1234 nes_remove_driver_sysfs(&nes_pci_driver);