RDMA/nes: Update copyright and branding string
[safe/jmp/linux-2.6] / drivers / infiniband / hw / nes / nes_nic.c
index 852546b..5a7b554 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2008 NetEffect, Inc. All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -91,6 +91,7 @@ static struct nic_qp_map *nic_qp_mapping_per_function[] = {
 static const u32 default_msg = NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK
                | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN;
 static int debug = -1;
+static int nics_per_function = 1;
 
 /**
  * nes_netdev_poll
@@ -98,7 +99,6 @@ static int debug = -1;
 static int nes_netdev_poll(struct napi_struct *napi, int budget)
 {
        struct nes_vnic *nesvnic = container_of(napi, struct nes_vnic, napi);
-       struct net_device *netdev = nesvnic->netdev;
        struct nes_device *nesdev = nesvnic->nesdev;
        struct nes_hw_nic_cq *nescq = &nesvnic->nic_cq;
 
@@ -111,7 +111,7 @@ static int nes_netdev_poll(struct napi_struct *napi, int budget)
        nes_nic_ce_handler(nesdev, nescq);
 
        if (nescq->cqes_pending == 0) {
-               netif_rx_complete(netdev, napi);
+               napi_complete(napi);
                /* clear out completed cqes and arm */
                nes_write32(nesdev->regs+NES_CQE_ALLOC, NES_CQE_ALLOC_NOTIFY_NEXT |
                                nescq->cq_number | (nescq->cqe_allocs_pending << 16));
@@ -201,7 +201,8 @@ static int nes_netdev_open(struct net_device *netdev)
                nes_debug(NES_DBG_NETDEV, "i=%d, perfect filter table index= %d, PERF FILTER LOW"
                                " (Addr:%08X) = %08X, HIGH = %08X.\n",
                                i, nesvnic->qp_nic_index[i],
-                               NES_IDX_PERFECT_FILTER_LOW+((nesvnic->perfect_filter_index + i) * 8),
+                               NES_IDX_PERFECT_FILTER_LOW+
+                                       (nesvnic->qp_nic_index[i] * 8),
                                macaddr_low,
                                (u32)macaddr_high | NES_MAC_ADDR_VALID |
                                ((((u32)nesvnic->nic_index) << 16)));
@@ -272,14 +273,18 @@ static int nes_netdev_stop(struct net_device *netdev)
                        break;
        }
 
-       if (first_nesvnic->netdev_open == 0)
+       if ((first_nesvnic->netdev_open == 1) && (first_nesvnic != nesvnic)  &&
+               (PCI_FUNC(first_nesvnic->nesdev->pcidev->devfn) !=
+               PCI_FUNC(nesvnic->nesdev->pcidev->devfn))) {
+                       nes_write_indexed(nesdev, NES_IDX_MAC_INT_MASK+
+                               (0x200*nesdev->mac_index), 0xffffffff);
+                       nes_write_indexed(first_nesvnic->nesdev,
+                               NES_IDX_MAC_INT_MASK+
+                               (0x200*first_nesvnic->nesdev->mac_index),
+                       ~(NES_MAC_INT_LINK_STAT_CHG | NES_MAC_INT_XGMII_EXT |
+                       NES_MAC_INT_TX_UNDERFLOW | NES_MAC_INT_TX_ERROR));
+       } else {
                nes_write_indexed(nesdev, NES_IDX_MAC_INT_MASK+(0x200*nesdev->mac_index), 0xffffffff);
-       else if ((first_nesvnic != nesvnic) &&
-                (PCI_FUNC(first_nesvnic->nesdev->pcidev->devfn) != PCI_FUNC(nesvnic->nesdev->pcidev->devfn))) {
-               nes_write_indexed(nesdev, NES_IDX_MAC_INT_MASK + (0x200 * nesdev->mac_index), 0xffffffff);
-               nes_write_indexed(first_nesvnic->nesdev, NES_IDX_MAC_INT_MASK + (0x200 * first_nesvnic->nesdev->mac_index),
-                               ~(NES_MAC_INT_LINK_STAT_CHG | NES_MAC_INT_XGMII_EXT |
-                               NES_MAC_INT_TX_UNDERFLOW | NES_MAC_INT_TX_ERROR));
        }
 
        nic_active_mask = ~((u32)(1 << nesvnic->nic_index));
@@ -395,8 +400,7 @@ static int nes_nic_send(struct sk_buff *skb, struct net_device *netdev)
        if (skb_headlen(skb) == skb->len) {
                if (skb_headlen(skb) <= NES_FIRST_FRAG_SIZE) {
                        nic_sqe->wqe_words[NES_NIC_SQ_WQE_LENGTH_2_1_IDX] = 0;
-                       nesnic->tx_skb[nesnic->sq_head] = NULL;
-                       dev_kfree_skb(skb);
+                       nesnic->tx_skb[nesnic->sq_head] = skb;
                }
        } else {
                /* Deal with Fragments */
@@ -448,7 +452,6 @@ static int nes_netdev_start_xmit(struct sk_buff *skb, struct net_device *netdev)
        u32 wqe_count=1;
        u32 send_rc;
        struct iphdr *iph;
-       unsigned long flags;
        __le16 *wqe_fragment_length;
        u32 nr_frags;
        u32 original_first_length;
@@ -475,13 +478,6 @@ static int nes_netdev_start_xmit(struct sk_buff *skb, struct net_device *netdev)
        if (netif_queue_stopped(netdev))
                return NETDEV_TX_BUSY;
 
-       local_irq_save(flags);
-       if (!spin_trylock(&nesnic->sq_lock)) {
-               local_irq_restore(flags);
-               nesvnic->sq_locked++;
-               return NETDEV_TX_LOCKED;
-       }
-
        /* Check if SQ is full */
        if ((((nesnic->sq_tail+(nesnic->sq_size*2))-nesnic->sq_head) & (nesnic->sq_size - 1)) == 1) {
                if (!netif_queue_stopped(netdev)) {
@@ -493,7 +489,6 @@ static int nes_netdev_start_xmit(struct sk_buff *skb, struct net_device *netdev)
                        }
                }
                nesvnic->sq_full++;
-               spin_unlock_irqrestore(&nesnic->sq_lock, flags);
                return NETDEV_TX_BUSY;
        }
 
@@ -526,7 +521,6 @@ sq_no_longer_full:
                                        }
                                }
                                nesvnic->sq_full++;
-                               spin_unlock_irqrestore(&nesnic->sq_lock, flags);
                                nes_debug(NES_DBG_NIC_TX, "%s: HNIC SQ full- TSO request has too many frags!\n",
                                                netdev->name);
                                return NETDEV_TX_BUSY;
@@ -651,17 +645,13 @@ tso_sq_no_longer_full:
                        skb_set_transport_header(skb, hoffset);
                        skb_set_network_header(skb, nhoffset);
                        send_rc = nes_nic_send(skb, netdev);
-                       if (send_rc != NETDEV_TX_OK) {
-                               spin_unlock_irqrestore(&nesnic->sq_lock, flags);
+                       if (send_rc != NETDEV_TX_OK)
                                return NETDEV_TX_OK;
-                       }
                }
        } else {
                send_rc = nes_nic_send(skb, netdev);
-               if (send_rc != NETDEV_TX_OK) {
-                       spin_unlock_irqrestore(&nesnic->sq_lock, flags);
+               if (send_rc != NETDEV_TX_OK)
                        return NETDEV_TX_OK;
-               }
        }
 
        barrier();
@@ -671,7 +661,6 @@ tso_sq_no_longer_full:
                                (wqe_count << 24) | (1 << 23) | nesvnic->nic.qp_id);
 
        netdev->trans_start = jiffies;
-       spin_unlock_irqrestore(&nesnic->sq_lock, flags);
 
        return NETDEV_TX_OK;
 }
@@ -791,14 +780,13 @@ static int nes_netdev_set_mac_address(struct net_device *netdev, void *p)
        int i;
        u32 macaddr_low;
        u16 macaddr_high;
-       DECLARE_MAC_BUF(mac);
 
        if (!is_valid_ether_addr(mac_addr->sa_data))
                return -EADDRNOTAVAIL;
 
        memcpy(netdev->dev_addr, mac_addr->sa_data, netdev->addr_len);
-       printk(PFX "%s: Address length = %d, Address = %s\n",
-              __func__, netdev->addr_len, print_mac(mac, mac_addr->sa_data));
+       printk(PFX "%s: Address length = %d, Address = %pM\n",
+              __func__, netdev->addr_len, mac_addr->sa_data);
        macaddr_high  = ((u16)netdev->dev_addr[0]) << 8;
        macaddr_high += (u16)netdev->dev_addr[1];
        macaddr_low   = ((u32)netdev->dev_addr[2]) << 24;
@@ -829,6 +817,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 {
        struct nes_vnic *nesvnic = netdev_priv(netdev);
        struct nes_device *nesdev = nesvnic->nesdev;
+       struct nes_adapter *nesadapter = nesvnic->nesdev->nesadapter;
        struct dev_mc_list *multicast_addr;
        u32 nic_active_bit;
        u32 nic_active;
@@ -838,7 +827,12 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
        u8 mc_all_on = 0;
        u8 mc_index;
        int mc_nic_index = -1;
+       u8 pft_entries_preallocated = max(nesadapter->adapter_fcn_count *
+                                       nics_per_function, 4);
+       u8 max_pft_entries_avaiable = NES_PFT_SIZE - pft_entries_preallocated;
+       unsigned long flags;
 
+       spin_lock_irqsave(&nesadapter->resource_lock, flags);
        nic_active_bit = 1 << nesvnic->nic_index;
 
        if (netdev->flags & IFF_PROMISC) {
@@ -849,7 +843,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
                nic_active |= nic_active_bit;
                nes_write_indexed(nesdev, NES_IDX_NIC_UNICAST_ALL, nic_active);
                mc_all_on = 1;
-       } else if ((netdev->flags & IFF_ALLMULTI) || (netdev->mc_count > NES_MULTICAST_PF_MAX) ||
+       } else if ((netdev->flags & IFF_ALLMULTI) ||
                           (nesvnic->nic_index > 3)) {
                nic_active = nes_read_indexed(nesdev, NES_IDX_NIC_MULTICAST_ALL);
                nic_active |= nic_active_bit;
@@ -868,21 +862,37 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
        }
 
        nes_debug(NES_DBG_NIC_RX, "Number of MC entries = %d, Promiscous = %d, All Multicast = %d.\n",
-                         netdev->mc_count, (netdev->flags & IFF_PROMISC)?1:0,
-                         (netdev->flags & IFF_ALLMULTI)?1:0);
+                 netdev->mc_count, !!(netdev->flags & IFF_PROMISC),
+                 !!(netdev->flags & IFF_ALLMULTI));
        if (!mc_all_on) {
                multicast_addr = netdev->mc_list;
-               perfect_filter_register_address = NES_IDX_PERFECT_FILTER_LOW + 0x80;
-               perfect_filter_register_address += nesvnic->nic_index*0x40;
-               for (mc_index=0; mc_index < NES_MULTICAST_PF_MAX; mc_index++) {
-                       while (multicast_addr && nesvnic->mcrq_mcast_filter && ((mc_nic_index = nesvnic->mcrq_mcast_filter(nesvnic, multicast_addr->dmi_addr)) == 0))
+               perfect_filter_register_address = NES_IDX_PERFECT_FILTER_LOW +
+                                               pft_entries_preallocated * 0x8;
+               for (mc_index = 0; mc_index < max_pft_entries_avaiable;
+               mc_index++) {
+                       while (multicast_addr && nesvnic->mcrq_mcast_filter &&
+                       ((mc_nic_index = nesvnic->mcrq_mcast_filter(nesvnic,
+                                       multicast_addr->dmi_addr)) == 0)) {
                                multicast_addr = multicast_addr->next;
+                       }
                        if (mc_nic_index < 0)
                                mc_nic_index = nesvnic->nic_index;
+                       while (nesadapter->pft_mcast_map[mc_index] < 16 &&
+                               nesadapter->pft_mcast_map[mc_index] !=
+                                       nesvnic->nic_index &&
+                                       mc_index < max_pft_entries_avaiable) {
+                                               nes_debug(NES_DBG_NIC_RX,
+                                       "mc_index=%d skipping nic_index=%d,\
+                                       used for=%d \n", mc_index,
+                                       nesvnic->nic_index,
+                                       nesadapter->pft_mcast_map[mc_index]);
+                               mc_index++;
+                       }
+                       if (mc_index >= max_pft_entries_avaiable)
+                               break;
                        if (multicast_addr) {
-                               DECLARE_MAC_BUF(mac);
-                               nes_debug(NES_DBG_NIC_RX, "Assigning MC Address %s to register 0x%04X nic_idx=%d\n",
-                                         print_mac(mac, multicast_addr->dmi_addr),
+                               nes_debug(NES_DBG_NIC_RX, "Assigning MC Address %pM to register 0x%04X nic_idx=%d\n",
+                                         multicast_addr->dmi_addr,
                                          perfect_filter_register_address+(mc_index * 8),
                                          mc_nic_index);
                                macaddr_high  = ((u16)multicast_addr->dmi_addr[0]) << 8;
@@ -899,15 +909,33 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
                                                (u32)macaddr_high | NES_MAC_ADDR_VALID |
                                                ((((u32)(1<<mc_nic_index)) << 16)));
                                multicast_addr = multicast_addr->next;
+                               nesadapter->pft_mcast_map[mc_index] =
+                                                       nesvnic->nic_index;
                        } else {
                                nes_debug(NES_DBG_NIC_RX, "Clearing MC Address at register 0x%04X\n",
                                                  perfect_filter_register_address+(mc_index * 8));
                                nes_write_indexed(nesdev,
                                                perfect_filter_register_address+4+(mc_index * 8),
                                                0);
+                               nesadapter->pft_mcast_map[mc_index] = 255;
                        }
                }
+               /* PFT is not large enough */
+               if (multicast_addr && multicast_addr->next) {
+                       nic_active = nes_read_indexed(nesdev,
+                                               NES_IDX_NIC_MULTICAST_ALL);
+                       nic_active |= nic_active_bit;
+                       nes_write_indexed(nesdev, NES_IDX_NIC_MULTICAST_ALL,
+                                                               nic_active);
+                       nic_active = nes_read_indexed(nesdev,
+                                               NES_IDX_NIC_UNICAST_ALL);
+                       nic_active &= ~nic_active_bit;
+                       nes_write_indexed(nesdev, NES_IDX_NIC_UNICAST_ALL,
+                                                               nic_active);
+               }
        }
+
+       spin_unlock_irqrestore(&nesadapter->resource_lock, flags);
 }
 
 
@@ -968,7 +996,6 @@ static const char nes_ethtool_stringset[][ETH_GSTRING_LEN] = {
        "Pause Frames Received",
        "Internal Routing Errors",
        "SQ SW Dropped SKBs",
-       "SQ Locked",
        "SQ Full",
        "Segmented TSO Requests",
        "Rx Symbol Errors",
@@ -1085,16 +1112,17 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
        struct nes_device *nesdev = nesvnic->nesdev;
        u32 nic_count;
        u32 u32temp;
+       u32 index = 0;
 
        target_ethtool_stats->n_stats = NES_ETHTOOL_STAT_COUNT;
-       target_stat_values[0] = nesvnic->nesdev->link_status_interrupts;
-       target_stat_values[1] = nesvnic->linearized_skbs;
-       target_stat_values[2] = nesvnic->tso_requests;
+       target_stat_values[index] = nesvnic->nesdev->link_status_interrupts;
+       target_stat_values[++index] = nesvnic->linearized_skbs;
+       target_stat_values[++index] = nesvnic->tso_requests;
 
        u32temp = nes_read_indexed(nesdev,
                        NES_IDX_MAC_TX_PAUSE_FRAMES + (nesvnic->nesdev->mac_index*0x200));
        nesvnic->nesdev->mac_pause_frames_sent += u32temp;
-       target_stat_values[3] = nesvnic->nesdev->mac_pause_frames_sent;
+       target_stat_values[++index] = nesvnic->nesdev->mac_pause_frames_sent;
 
        u32temp = nes_read_indexed(nesdev,
                        NES_IDX_MAC_RX_PAUSE_FRAMES + (nesvnic->nesdev->mac_index*0x200));
@@ -1165,60 +1193,59 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
                nesvnic->endnode_ipv4_tcp_retransmits += u32temp;
        }
 
-       target_stat_values[4] = nesvnic->nesdev->mac_pause_frames_received;
-       target_stat_values[5] = nesdev->nesadapter->nic_rx_eth_route_err;
-       target_stat_values[6] = nesvnic->tx_sw_dropped;
-       target_stat_values[7] = nesvnic->sq_locked;
-       target_stat_values[8] = nesvnic->sq_full;
-       target_stat_values[9] = nesvnic->segmented_tso_requests;
-       target_stat_values[10] = nesvnic->nesdev->mac_rx_symbol_err_frames;
-       target_stat_values[11] = nesvnic->nesdev->mac_rx_jabber_frames;
-       target_stat_values[12] = nesvnic->nesdev->mac_rx_oversized_frames;
-       target_stat_values[13] = nesvnic->nesdev->mac_rx_short_frames;
-       target_stat_values[14] = nesvnic->endnode_nstat_rx_discard;
-       target_stat_values[15] = nesvnic->endnode_nstat_rx_octets;
-       target_stat_values[16] = nesvnic->endnode_nstat_rx_frames;
-       target_stat_values[17] = nesvnic->endnode_nstat_tx_octets;
-       target_stat_values[18] = nesvnic->endnode_nstat_tx_frames;
-       target_stat_values[19] = mh_detected;
-       target_stat_values[20] = mh_pauses_sent;
-       target_stat_values[21] = nesvnic->endnode_ipv4_tcp_retransmits;
-       target_stat_values[22] = atomic_read(&cm_connects);
-       target_stat_values[23] = atomic_read(&cm_accepts);
-       target_stat_values[24] = atomic_read(&cm_disconnects);
-       target_stat_values[25] = atomic_read(&cm_connecteds);
-       target_stat_values[26] = atomic_read(&cm_connect_reqs);
-       target_stat_values[27] = atomic_read(&cm_rejects);
-       target_stat_values[28] = atomic_read(&mod_qp_timouts);
-       target_stat_values[29] = atomic_read(&qps_created);
-       target_stat_values[30] = atomic_read(&sw_qps_destroyed);
-       target_stat_values[31] = atomic_read(&qps_destroyed);
-       target_stat_values[32] = atomic_read(&cm_closes);
-       target_stat_values[33] = cm_packets_sent;
-       target_stat_values[34] = cm_packets_bounced;
-       target_stat_values[35] = cm_packets_created;
-       target_stat_values[36] = cm_packets_received;
-       target_stat_values[37] = cm_packets_dropped;
-       target_stat_values[38] = cm_packets_retrans;
-       target_stat_values[39] = cm_listens_created;
-       target_stat_values[40] = cm_listens_destroyed;
-       target_stat_values[41] = cm_backlog_drops;
-       target_stat_values[42] = atomic_read(&cm_loopbacks);
-       target_stat_values[43] = atomic_read(&cm_nodes_created);
-       target_stat_values[44] = atomic_read(&cm_nodes_destroyed);
-       target_stat_values[45] = atomic_read(&cm_accel_dropped_pkts);
-       target_stat_values[46] = atomic_read(&cm_resets_recvd);
-       target_stat_values[47] = int_mod_timer_init;
-       target_stat_values[48] = int_mod_cq_depth_1;
-       target_stat_values[49] = int_mod_cq_depth_4;
-       target_stat_values[50] = int_mod_cq_depth_16;
-       target_stat_values[51] = int_mod_cq_depth_24;
-       target_stat_values[52] = int_mod_cq_depth_32;
-       target_stat_values[53] = int_mod_cq_depth_128;
-       target_stat_values[54] = int_mod_cq_depth_256;
-       target_stat_values[55] = nesvnic->lro_mgr.stats.aggregated;
-       target_stat_values[56] = nesvnic->lro_mgr.stats.flushed;
-       target_stat_values[57] = nesvnic->lro_mgr.stats.no_desc;
+       target_stat_values[++index] = nesvnic->nesdev->mac_pause_frames_received;
+       target_stat_values[++index] = nesdev->nesadapter->nic_rx_eth_route_err;
+       target_stat_values[++index] = nesvnic->tx_sw_dropped;
+       target_stat_values[++index] = nesvnic->sq_full;
+       target_stat_values[++index] = nesvnic->segmented_tso_requests;
+       target_stat_values[++index] = nesvnic->nesdev->mac_rx_symbol_err_frames;
+       target_stat_values[++index] = nesvnic->nesdev->mac_rx_jabber_frames;
+       target_stat_values[++index] = nesvnic->nesdev->mac_rx_oversized_frames;
+       target_stat_values[++index] = nesvnic->nesdev->mac_rx_short_frames;
+       target_stat_values[++index] = nesvnic->endnode_nstat_rx_discard;
+       target_stat_values[++index] = nesvnic->endnode_nstat_rx_octets;
+       target_stat_values[++index] = nesvnic->endnode_nstat_rx_frames;
+       target_stat_values[++index] = nesvnic->endnode_nstat_tx_octets;
+       target_stat_values[++index] = nesvnic->endnode_nstat_tx_frames;
+       target_stat_values[++index] = mh_detected;
+       target_stat_values[++index] = mh_pauses_sent;
+       target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
+       target_stat_values[++index] = atomic_read(&cm_connects);
+       target_stat_values[++index] = atomic_read(&cm_accepts);
+       target_stat_values[++index] = atomic_read(&cm_disconnects);
+       target_stat_values[++index] = atomic_read(&cm_connecteds);
+       target_stat_values[++index] = atomic_read(&cm_connect_reqs);
+       target_stat_values[++index] = atomic_read(&cm_rejects);
+       target_stat_values[++index] = atomic_read(&mod_qp_timouts);
+       target_stat_values[++index] = atomic_read(&qps_created);
+       target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
+       target_stat_values[++index] = atomic_read(&qps_destroyed);
+       target_stat_values[++index] = atomic_read(&cm_closes);
+       target_stat_values[++index] = cm_packets_sent;
+       target_stat_values[++index] = cm_packets_bounced;
+       target_stat_values[++index] = cm_packets_created;
+       target_stat_values[++index] = cm_packets_received;
+       target_stat_values[++index] = cm_packets_dropped;
+       target_stat_values[++index] = cm_packets_retrans;
+       target_stat_values[++index] = cm_listens_created;
+       target_stat_values[++index] = cm_listens_destroyed;
+       target_stat_values[++index] = cm_backlog_drops;
+       target_stat_values[++index] = atomic_read(&cm_loopbacks);
+       target_stat_values[++index] = atomic_read(&cm_nodes_created);
+       target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
+       target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
+       target_stat_values[++index] = atomic_read(&cm_resets_recvd);
+       target_stat_values[++index] = int_mod_timer_init;
+       target_stat_values[++index] = int_mod_cq_depth_1;
+       target_stat_values[++index] = int_mod_cq_depth_4;
+       target_stat_values[++index] = int_mod_cq_depth_16;
+       target_stat_values[++index] = int_mod_cq_depth_24;
+       target_stat_values[++index] = int_mod_cq_depth_32;
+       target_stat_values[++index] = int_mod_cq_depth_128;
+       target_stat_values[++index] = int_mod_cq_depth_256;
+       target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
+       target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
+       target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
 
 }
 
@@ -1399,49 +1426,55 @@ static int nes_netdev_get_settings(struct net_device *netdev, struct ethtool_cmd
        struct nes_vnic *nesvnic = netdev_priv(netdev);
        struct nes_device *nesdev = nesvnic->nesdev;
        struct nes_adapter *nesadapter = nesdev->nesadapter;
+       u32 mac_index = nesdev->mac_index;
+       u8 phy_type = nesadapter->phy_type[mac_index];
+       u8 phy_index = nesadapter->phy_index[mac_index];
        u16 phy_data;
 
        et_cmd->duplex = DUPLEX_FULL;
        et_cmd->port   = PORT_MII;
+       et_cmd->maxtxpkt = 511;
+       et_cmd->maxrxpkt = 511;
 
        if (nesadapter->OneG_Mode) {
                et_cmd->speed = SPEED_1000;
-               if (nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_PUMA_1G) {
+               if (phy_type == NES_PHY_TYPE_PUMA_1G) {
                        et_cmd->supported   = SUPPORTED_1000baseT_Full;
                        et_cmd->advertising = ADVERTISED_1000baseT_Full;
                        et_cmd->autoneg     = AUTONEG_DISABLE;
                        et_cmd->transceiver = XCVR_INTERNAL;
-                       et_cmd->phy_address = nesdev->mac_index;
+                       et_cmd->phy_address = mac_index;
                } else {
-                       et_cmd->supported   = SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg;
-                       et_cmd->advertising = ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg;
-                       nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[nesdev->mac_index], &phy_data);
+                       et_cmd->supported   = SUPPORTED_1000baseT_Full
+                                           | SUPPORTED_Autoneg;
+                       et_cmd->advertising = ADVERTISED_1000baseT_Full
+                                           | ADVERTISED_Autoneg;
+                       nes_read_1G_phy_reg(nesdev, 0, phy_index, &phy_data);
                        if (phy_data & 0x1000)
                                et_cmd->autoneg = AUTONEG_ENABLE;
                        else
                                et_cmd->autoneg = AUTONEG_DISABLE;
                        et_cmd->transceiver = XCVR_EXTERNAL;
-                       et_cmd->phy_address = nesadapter->phy_index[nesdev->mac_index];
+                       et_cmd->phy_address = phy_index;
                }
+               return 0;
+       }
+       if ((phy_type == NES_PHY_TYPE_IRIS) ||
+           (phy_type == NES_PHY_TYPE_ARGUS) ||
+           (phy_type == NES_PHY_TYPE_SFP_D)) {
+               et_cmd->transceiver = XCVR_EXTERNAL;
+               et_cmd->port        = PORT_FIBRE;
+               et_cmd->supported   = SUPPORTED_FIBRE;
+               et_cmd->advertising = ADVERTISED_FIBRE;
+               et_cmd->phy_address = phy_index;
        } else {
-               if ((nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_IRIS) ||
-                   (nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_ARGUS)) {
-                       et_cmd->transceiver = XCVR_EXTERNAL;
-                       et_cmd->port        = PORT_FIBRE;
-                       et_cmd->supported   = SUPPORTED_FIBRE;
-                       et_cmd->advertising = ADVERTISED_FIBRE;
-                       et_cmd->phy_address = nesadapter->phy_index[nesdev->mac_index];
-               } else {
-                       et_cmd->transceiver = XCVR_INTERNAL;
-                       et_cmd->supported   = SUPPORTED_10000baseT_Full;
-                       et_cmd->advertising = ADVERTISED_10000baseT_Full;
-                       et_cmd->phy_address = nesdev->mac_index;
-               }
-               et_cmd->speed = SPEED_10000;
-               et_cmd->autoneg = AUTONEG_DISABLE;
+               et_cmd->transceiver = XCVR_INTERNAL;
+               et_cmd->supported   = SUPPORTED_10000baseT_Full;
+               et_cmd->advertising = ADVERTISED_10000baseT_Full;
+               et_cmd->phy_address = mac_index;
        }
-       et_cmd->maxtxpkt = 511;
-       et_cmd->maxrxpkt = 511;
+       et_cmd->speed = SPEED_10000;
+       et_cmd->autoneg = AUTONEG_DISABLE;
        return 0;
 }
 
@@ -1475,7 +1508,7 @@ static int nes_netdev_set_settings(struct net_device *netdev, struct ethtool_cmd
 }
 
 
-static struct ethtool_ops nes_ethtool_ops = {
+static const struct ethtool_ops nes_ethtool_ops = {
        .get_link = ethtool_op_get_link,
        .get_settings = nes_netdev_get_settings,
        .set_settings = nes_netdev_set_settings,
@@ -1524,6 +1557,18 @@ static void nes_netdev_vlan_rx_register(struct net_device *netdev, struct vlan_g
        spin_unlock_irqrestore(&nesadapter->phy_lock, flags);
 }
 
+static const struct net_device_ops nes_netdev_ops = {
+       .ndo_open               = nes_netdev_open,
+       .ndo_stop               = nes_netdev_stop,
+       .ndo_start_xmit         = nes_netdev_start_xmit,
+       .ndo_get_stats          = nes_netdev_get_stats,
+       .ndo_tx_timeout         = nes_netdev_tx_timeout,
+       .ndo_set_mac_address    = nes_netdev_set_mac_address,
+       .ndo_set_multicast_list = nes_netdev_set_multicast_list,
+       .ndo_change_mtu         = nes_netdev_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_vlan_rx_register   = nes_netdev_vlan_rx_register,
+};
 
 /**
  * nes_netdev_init - initialize network device
@@ -1532,7 +1577,7 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
                void __iomem *mmio_addr)
 {
        u64 u64temp;
-       struct nes_vnic *nesvnic = NULL;
+       struct nes_vnic *nesvnic;
        struct net_device *netdev;
        struct nic_qp_map *curr_qp_map;
        u32 u32temp;
@@ -1544,22 +1589,12 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
                printk(KERN_ERR PFX "nesvnic etherdev alloc failed");
                return NULL;
        }
+       nesvnic = netdev_priv(netdev);
 
        nes_debug(NES_DBG_INIT, "netdev = %p, %s\n", netdev, netdev->name);
 
        SET_NETDEV_DEV(netdev, &nesdev->pcidev->dev);
 
-       nesvnic = netdev_priv(netdev);
-       memset(nesvnic, 0, sizeof(*nesvnic));
-
-       netdev->open = nes_netdev_open;
-       netdev->stop = nes_netdev_stop;
-       netdev->hard_start_xmit = nes_netdev_start_xmit;
-       netdev->get_stats = nes_netdev_get_stats;
-       netdev->tx_timeout = nes_netdev_tx_timeout;
-       netdev->set_mac_address = nes_netdev_set_mac_address;
-       netdev->set_multicast_list = nes_netdev_set_multicast_list;
-       netdev->change_mtu = nes_netdev_change_mtu;
        netdev->watchdog_timeo = NES_TX_TIMEOUT;
        netdev->irq = nesdev->pcidev->irq;
        netdev->mtu = ETH_DATA_LEN;
@@ -1567,12 +1602,11 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
        netdev->addr_len = ETH_ALEN;
        netdev->type = ARPHRD_ETHER;
        netdev->features = NETIF_F_HIGHDMA;
+       netdev->netdev_ops = &nes_netdev_ops;
        netdev->ethtool_ops = &nes_ethtool_ops;
        netif_napi_add(netdev, &nesvnic->napi, nes_netdev_poll, 128);
        nes_debug(NES_DBG_INIT, "Enabling VLAN Insert/Delete.\n");
        netdev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
-       netdev->vlan_rx_register = nes_netdev_vlan_rx_register;
-       netdev->features |= NETIF_F_LLTX;
 
        /* Fill in the port structure */
        nesvnic->netdev = netdev;
@@ -1611,7 +1645,9 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
                        nesvnic, (unsigned long)netdev->features, nesvnic->nic.qp_id,
                        nesvnic->nic_index, nesvnic->logical_port,  nesdev->mac_index);
 
-       if (nesvnic->nesdev->nesadapter->port_count == 1) {
+       if (nesvnic->nesdev->nesadapter->port_count == 1 &&
+               nesvnic->nesdev->nesadapter->adapter_fcn_count == 1) {
+
                nesvnic->qp_nic_index[0] = nesvnic->nic_index;
                nesvnic->qp_nic_index[1] = nesvnic->nic_index + 1;
                if (nes_drv_opt & NES_DRV_OPT_DUAL_LOGICAL_PORT) {
@@ -1622,11 +1658,14 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
                        nesvnic->qp_nic_index[3] = nesvnic->nic_index + 3;
                }
        } else {
-               if (nesvnic->nesdev->nesadapter->port_count == 2) {
-                       nesvnic->qp_nic_index[0] = nesvnic->nic_index;
-                       nesvnic->qp_nic_index[1] = nesvnic->nic_index + 2;
-                       nesvnic->qp_nic_index[2] = 0xf;
-                       nesvnic->qp_nic_index[3] = 0xf;
+               if (nesvnic->nesdev->nesadapter->port_count == 2 ||
+                       (nesvnic->nesdev->nesadapter->port_count == 1 &&
+                       nesvnic->nesdev->nesadapter->adapter_fcn_count == 2)) {
+                               nesvnic->qp_nic_index[0] = nesvnic->nic_index;
+                               nesvnic->qp_nic_index[1] = nesvnic->nic_index
+                                                                       + 2;
+                               nesvnic->qp_nic_index[2] = 0xf;
+                               nesvnic->qp_nic_index[3] = 0xf;
                } else {
                        nesvnic->qp_nic_index[0] = nesvnic->nic_index;
                        nesvnic->qp_nic_index[1] = 0xf;