Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[cascardo/linux.git] / drivers / net / ethernet / cavium / thunder / nicvf_main.c
index 3240349..7d00162 100644 (file)
 static const struct pci_device_id nicvf_id_table[] = {
        { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM,
                         PCI_DEVICE_ID_THUNDER_NIC_VF,
-                        PCI_VENDOR_ID_CAVIUM, 0xA134) },
+                        PCI_VENDOR_ID_CAVIUM,
+                        PCI_SUBSYS_DEVID_88XX_NIC_VF) },
        { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM,
                         PCI_DEVICE_ID_THUNDER_PASS1_NIC_VF,
-                        PCI_VENDOR_ID_CAVIUM, 0xA11E) },
+                        PCI_VENDOR_ID_CAVIUM,
+                        PCI_SUBSYS_DEVID_88XX_PASS1_NIC_VF) },
+       { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM,
+                        PCI_DEVICE_ID_THUNDER_NIC_VF,
+                        PCI_VENDOR_ID_CAVIUM,
+                        PCI_SUBSYS_DEVID_81XX_NIC_VF) },
+       { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM,
+                        PCI_DEVICE_ID_THUNDER_NIC_VF,
+                        PCI_VENDOR_ID_CAVIUM,
+                        PCI_SUBSYS_DEVID_83XX_NIC_VF) },
        { 0, }  /* end of table */
 };
 
@@ -134,15 +144,19 @@ int nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx)
 
        /* Wait for previous message to be acked, timeout 2sec */
        while (!nic->pf_acked) {
-               if (nic->pf_nacked)
+               if (nic->pf_nacked) {
+                       netdev_err(nic->netdev,
+                                  "PF NACK to mbox msg 0x%02x from VF%d\n",
+                                  (mbx->msg.msg & 0xFF), nic->vf_id);
                        return -EINVAL;
+               }
                msleep(sleep);
                if (nic->pf_acked)
                        break;
                timeout -= sleep;
                if (!timeout) {
                        netdev_err(nic->netdev,
-                                  "PF didn't ack to mbox msg %d from VF%d\n",
+                                  "PF didn't ACK to mbox msg 0x%02x from VF%d\n",
                                   (mbx->msg.msg & 0xFF), nic->vf_id);
                        return -EBUSY;
                }
@@ -352,13 +366,7 @@ static int nicvf_rss_init(struct nicvf *nic)
 
        rss->enable = true;
 
-       /* Using the HW reset value for now */
-       rss->key[0] = 0xFEED0BADFEED0BADULL;
-       rss->key[1] = 0xFEED0BADFEED0BADULL;
-       rss->key[2] = 0xFEED0BADFEED0BADULL;
-       rss->key[3] = 0xFEED0BADFEED0BADULL;
-       rss->key[4] = 0xFEED0BADFEED0BADULL;
-
+       netdev_rss_key_fill(rss->key, RSS_HASH_KEY_SIZE * sizeof(u64));
        nicvf_set_rss_key(nic);
 
        rss->cfg = RSS_IP_HASH_ENA | RSS_TCP_HASH_ENA | RSS_UDP_HASH_ENA;
@@ -507,7 +515,8 @@ static int nicvf_init_resources(struct nicvf *nic)
 
 static void nicvf_snd_pkt_handler(struct net_device *netdev,
                                  struct cmp_queue *cq,
-                                 struct cqe_send_t *cqe_tx, int cqe_type)
+                                 struct cqe_send_t *cqe_tx,
+                                 int cqe_type, int budget)
 {
        struct sk_buff *skb = NULL;
        struct nicvf *nic = netdev_priv(netdev);
@@ -538,7 +547,7 @@ static void nicvf_snd_pkt_handler(struct net_device *netdev,
                }
                nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1);
                prefetch(skb);
-               dev_consume_skb_any(skb);
+               napi_consume_skb(skb, budget);
                sq->skbuff[cqe_tx->sqe_ptr] = (u64)NULL;
        } else {
                /* In case of SW TSO on 88xx, only last segment will have
@@ -691,7 +700,8 @@ loop:
                break;
                case CQE_TYPE_SEND:
                        nicvf_snd_pkt_handler(netdev, cq,
-                                             (void *)cq_desc, CQE_TYPE_SEND);
+                                             (void *)cq_desc, CQE_TYPE_SEND,
+                                             budget);
                        tx_done++;
                break;
                case CQE_TYPE_INVALID:
@@ -933,16 +943,19 @@ static int nicvf_register_interrupts(struct nicvf *nic)
        int vector;
 
        for_each_cq_irq(irq)
-               sprintf(nic->irq_name[irq], "NICVF%d CQ%d",
-                       nic->vf_id, irq);
+               sprintf(nic->irq_name[irq], "%s-rxtx-%d",
+                       nic->pnicvf->netdev->name,
+                       nicvf_netdev_qidx(nic, irq));
 
        for_each_sq_irq(irq)
-               sprintf(nic->irq_name[irq], "NICVF%d SQ%d",
-                       nic->vf_id, irq - NICVF_INTR_ID_SQ);
+               sprintf(nic->irq_name[irq], "%s-sq-%d",
+                       nic->pnicvf->netdev->name,
+                       nicvf_netdev_qidx(nic, irq - NICVF_INTR_ID_SQ));
 
        for_each_rbdr_irq(irq)
-               sprintf(nic->irq_name[irq], "NICVF%d RBDR%d",
-                       nic->vf_id, irq - NICVF_INTR_ID_RBDR);
+               sprintf(nic->irq_name[irq], "%s-rbdr-%d",
+                       nic->pnicvf->netdev->name,
+                       nic->sqs_mode ? (nic->sqs_id + 1) : 0);
 
        /* Register CQ interrupts */
        for (irq = 0; irq < nic->qs->cq_cnt; irq++) {
@@ -966,8 +979,9 @@ static int nicvf_register_interrupts(struct nicvf *nic)
        }
 
        /* Register QS error interrupt */
-       sprintf(nic->irq_name[NICVF_INTR_ID_QS_ERR],
-               "NICVF%d Qset error", nic->vf_id);
+       sprintf(nic->irq_name[NICVF_INTR_ID_QS_ERR], "%s-qset-err-%d",
+               nic->pnicvf->netdev->name,
+               nic->sqs_mode ? (nic->sqs_id + 1) : 0);
        irq = NICVF_INTR_ID_QS_ERR;
        ret = request_irq(nic->msix_entries[irq].vector,
                          nicvf_qs_err_intr_handler,
@@ -1196,7 +1210,7 @@ int nicvf_open(struct net_device *netdev)
        }
 
        /* Check if we got MAC address from PF or else generate a radom MAC */
-       if (is_zero_ether_addr(netdev->dev_addr)) {
+       if (!nic->sqs_mode && is_zero_ether_addr(netdev->dev_addr)) {
                eth_hw_addr_random(netdev);
                nicvf_hw_set_mac_addr(nic, netdev);
        }
@@ -1533,14 +1547,13 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto err_release_regions;
        }
 
-       qcount = MAX_CMP_QUEUES_PER_QS;
+       qcount = netif_get_num_default_rss_queues();
 
        /* Restrict multiqset support only for host bound VFs */
        if (pdev->is_virtfn) {
                /* Set max number of queues per VF */
-               qcount = roundup(num_online_cpus(), MAX_CMP_QUEUES_PER_QS);
-               qcount = min(qcount,
-                            (MAX_SQS_PER_VF + 1) * MAX_CMP_QUEUES_PER_QS);
+               qcount = min_t(int, num_online_cpus(),
+                              (MAX_SQS_PER_VF + 1) * MAX_CMP_QUEUES_PER_QS);
        }
 
        netdev = alloc_etherdev_mqs(sizeof(struct nicvf), qcount, qcount);