]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/net/myri10ge/myri10ge.c
[PATCH] ethtool: allow const ethtool_ops
[mirror_ubuntu-artful-kernel.git] / drivers / net / myri10ge / myri10ge.c
index a79afe2134ba65de63cf4fef2f13467d03f0d1f2..b19e2034d11fc2df0ac20d974bafa2df7f837653 100644 (file)
@@ -187,6 +187,7 @@ struct myri10ge_priv {
        u8 mac_addr[6];         /* eeprom mac address */
        unsigned long serial_number;
        int vendor_specific_offset;
+       int fw_multicast_support;
        u32 devctl;
        u16 msi_flags;
        u32 read_dma;
@@ -328,6 +329,8 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
                if (result == 0) {
                        data->data0 = value;
                        return 0;
+               } else if (result == MXGEFW_CMD_UNKNOWN) {
+                       return -ENOSYS;
                } else {
                        dev_err(&mgp->pdev->dev,
                                "command %d failed, result = %d\n",
@@ -1309,8 +1312,8 @@ static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = {
        "tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt",
        "wake_queue", "stop_queue", "watchdog_resets", "tx_linearized",
        "link_changes", "link_up", "dropped_link_overflow",
-       "dropped_link_error_or_filtered", "dropped_runt",
-       "dropped_overrun", "dropped_no_small_buffer",
+       "dropped_link_error_or_filtered", "dropped_multicast_filtered",
+       "dropped_runt", "dropped_overrun", "dropped_no_small_buffer",
        "dropped_no_big_buffer"
 };
 
@@ -1366,6 +1369,8 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
        data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_link_overflow);
        data[i++] =
            (unsigned int)ntohl(mgp->fw_stats->dropped_link_error_or_filtered);
+       data[i++] =
+           (unsigned int)ntohl(mgp->fw_stats->dropped_multicast_filtered);
        data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_runt);
        data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_overrun);
        data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_small_buffer);
@@ -1722,7 +1727,21 @@ static int myri10ge_open(struct net_device *dev)
 
        cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->fw_stats_bus);
        cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->fw_stats_bus);
-       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA, &cmd, 0);
+       cmd.data2 = sizeof(struct mcp_irq_data);
+       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0);
+       if (status == -ENOSYS) {
+               dma_addr_t bus = mgp->fw_stats_bus;
+               bus += offsetof(struct mcp_irq_data, send_done_count);
+               cmd.data0 = MYRI10GE_LOWPART_TO_U32(bus);
+               cmd.data1 = MYRI10GE_HIGHPART_TO_U32(bus);
+               status = myri10ge_send_cmd(mgp,
+                                          MXGEFW_CMD_SET_STATS_DMA_OBSOLETE,
+                                          &cmd, 0);
+               /* Firmware cannot support multicast without STATS_DMA_V2 */
+               mgp->fw_multicast_support = 0;
+       } else {
+               mgp->fw_multicast_support = 1;
+       }
        if (status) {
                printk(KERN_ERR "myri10ge: %s: Couldn't set stats DMA\n",
                       dev->name);
@@ -2177,9 +2196,81 @@ static struct net_device_stats *myri10ge_get_stats(struct net_device *dev)
 
 static void myri10ge_set_multicast_list(struct net_device *dev)
 {
+       struct myri10ge_cmd cmd;
+       struct myri10ge_priv *mgp;
+       struct dev_mc_list *mc_list;
+       int err;
+
+       mgp = netdev_priv(dev);
        /* can be called from atomic contexts,
         * pass 1 to force atomicity in myri10ge_send_cmd() */
-       myri10ge_change_promisc(netdev_priv(dev), dev->flags & IFF_PROMISC, 1);
+       myri10ge_change_promisc(mgp, dev->flags & IFF_PROMISC, 1);
+
+       /* This firmware is known to not support multicast */
+       if (!mgp->fw_multicast_support)
+               return;
+
+       /* Disable multicast filtering */
+
+       err = myri10ge_send_cmd(mgp, MXGEFW_ENABLE_ALLMULTI, &cmd, 1);
+       if (err != 0) {
+               printk(KERN_ERR "myri10ge: %s: Failed MXGEFW_ENABLE_ALLMULTI,"
+                      " error status: %d\n", dev->name, err);
+               goto abort;
+       }
+
+       if (dev->flags & IFF_ALLMULTI) {
+               /* request to disable multicast filtering, so quit here */
+               return;
+       }
+
+       /* Flush the filters */
+
+       err = myri10ge_send_cmd(mgp, MXGEFW_LEAVE_ALL_MULTICAST_GROUPS,
+                               &cmd, 1);
+       if (err != 0) {
+               printk(KERN_ERR
+                      "myri10ge: %s: Failed MXGEFW_LEAVE_ALL_MULTICAST_GROUPS"
+                      ", error status: %d\n", dev->name, err);
+               goto abort;
+       }
+
+       /* Walk the multicast list, and add each address */
+       for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) {
+               memcpy(&cmd.data0, &mc_list->dmi_addr, 4);
+               memcpy(&cmd.data1, ((char *)&mc_list->dmi_addr) + 4, 2);
+               cmd.data0 = htonl(cmd.data0);
+               cmd.data1 = htonl(cmd.data1);
+               err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP,
+                                       &cmd, 1);
+
+               if (err != 0) {
+                       printk(KERN_ERR "myri10ge: %s: Failed "
+                              "MXGEFW_JOIN_MULTICAST_GROUP, error status:"
+                              "%d\t", dev->name, err);
+                       printk(KERN_ERR "MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
+                              ((unsigned char *)&mc_list->dmi_addr)[0],
+                              ((unsigned char *)&mc_list->dmi_addr)[1],
+                              ((unsigned char *)&mc_list->dmi_addr)[2],
+                              ((unsigned char *)&mc_list->dmi_addr)[3],
+                              ((unsigned char *)&mc_list->dmi_addr)[4],
+                              ((unsigned char *)&mc_list->dmi_addr)[5]
+                           );
+                       goto abort;
+               }
+       }
+       /* Enable multicast filtering */
+       err = myri10ge_send_cmd(mgp, MXGEFW_DISABLE_ALLMULTI, &cmd, 1);
+       if (err != 0) {
+               printk(KERN_ERR "myri10ge: %s: Failed MXGEFW_DISABLE_ALLMULTI,"
+                      "error status: %d\n", dev->name, err);
+               goto abort;
+       }
+
+       return;
+
+abort:
+       return;
 }
 
 static int myri10ge_set_mac_address(struct net_device *dev, void *addr)
@@ -2326,6 +2417,8 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
  */
 
 #define PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE  0x0132
+#define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7
+#define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa
 
 static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
 {
@@ -2335,15 +2428,34 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
        mgp->fw_name = myri10ge_fw_unaligned;
 
        if (myri10ge_force_firmware == 0) {
+               int link_width, exp_cap;
+               u16 lnk;
+
+               exp_cap = pci_find_capability(mgp->pdev, PCI_CAP_ID_EXP);
+               pci_read_config_word(mgp->pdev, exp_cap + PCI_EXP_LNKSTA, &lnk);
+               link_width = (lnk >> 4) & 0x3f;
+
                myri10ge_enable_ecrc(mgp);
 
-               /* Check to see if the upstream bridge is known to
-                * provide aligned completions */
-               if (bridge
-                   /* ServerWorks HT2000/HT1000 */
-                   && bridge->vendor == PCI_VENDOR_ID_SERVERWORKS
-                   && bridge->device ==
-                   PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE) {
+               /* Check to see if Link is less than 8 or if the
+                * upstream bridge is known to provide aligned
+                * completions */
+               if (link_width < 8) {
+                       dev_info(&mgp->pdev->dev, "PCIE x%d Link\n",
+                                link_width);
+                       mgp->tx.boundary = 4096;
+                       mgp->fw_name = myri10ge_fw_aligned;
+               } else if (bridge &&
+                          /* ServerWorks HT2000/HT1000 */
+                          ((bridge->vendor == PCI_VENDOR_ID_SERVERWORKS
+                            && bridge->device ==
+                            PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE)
+                           /* All Intel E5000 PCIE ports */
+                           || (bridge->vendor == PCI_VENDOR_ID_INTEL
+                               && bridge->device >=
+                               PCI_DEVICE_ID_INTEL_E5000_PCIE23
+                               && bridge->device <=
+                               PCI_DEVICE_ID_INTEL_E5000_PCIE47))) {
                        dev_info(&mgp->pdev->dev,
                                 "Assuming aligned completions (0x%x:0x%x)\n",
                                 bridge->vendor, bridge->device);