Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/ixgbe FreeBSD r320688 sorted a lot of functions....



details:   https://anonhg.NetBSD.org/src/rev/8e75368aa4bf
branches:  trunk
changeset: 826367:8e75368aa4bf
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Aug 30 08:24:57 2017 +0000

description:
FreeBSD r320688 sorted a lot of functions. Merging that change by one commit
makes difficult to know what was really changed. To make change understandable,
commit only function sort and white space changes before real change.

diffstat:

 sys/dev/pci/ixgbe/ixgbe.c |  7559 ++++++++++++++++++++++----------------------
 sys/dev/pci/ixgbe/ixv.c   |  1068 +++---
 2 files changed, 4322 insertions(+), 4305 deletions(-)

diffs (truncated from 8974 to 300 lines):

diff -r 018dd6ff674c -r 8e75368aa4bf sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Wed Aug 30 05:47:24 2017 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Wed Aug 30 08:24:57 2017 +0000
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.97 2017/08/30 01:25:07 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.98 2017/08/30 08:24:57 msaitoh Exp $*/
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -147,6 +147,7 @@
 #endif
 static bool    ixgbe_suspend(device_t, const pmf_qual_t *);
 static bool    ixgbe_resume(device_t, const pmf_qual_t *);
+static int     ixgbe_ifflags_cb(struct ethercom *);
 static int      ixgbe_ioctl(struct ifnet *, u_long, void *);
 static void    ixgbe_ifstop(struct ifnet *, int);
 static int     ixgbe_init(struct ifnet *);
@@ -209,6 +210,7 @@
                     const char *, int *, int);
 static int     ixgbe_sysctl_flowcntl(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_advertise(SYSCTLFN_PROTO);
+static int      ixgbe_sysctl_interrupt_rate_handler(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_thermal_test(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_dmac(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_phy_temp(SYSCTLFN_PROTO);
@@ -217,6 +219,10 @@
 static int     ixgbe_sysctl_power_state(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_print_rss_config(SYSCTLFN_PROTO);
 #endif
+static int      ixgbe_sysctl_rdh_handler(SYSCTLFN_PROTO);
+static int      ixgbe_sysctl_rdt_handler(SYSCTLFN_PROTO);
+static int      ixgbe_sysctl_tdt_handler(SYSCTLFN_PROTO);
+static int      ixgbe_sysctl_tdh_handler(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_wol_enable(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_wufc(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_eee_enable(SYSCTLFN_PROTO);
@@ -406,50 +412,393 @@
 #define IXGBE_SOFTINFT_FLAGS   0
 #endif
 
+static void
+ixgbe_initialize_rss_mapping(struct adapter *adapter)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+       u32 reta = 0, mrqc, rss_key[10];
+       int queue_id, table_size, index_mult;
+#ifdef RSS
+       u32 rss_hash_config;
+#endif
+#ifdef PCI_IOV
+       enum ixgbe_iov_mode mode;
+#endif
+
+#ifdef RSS
+       /* Fetch the configured RSS key */
+       rss_getkey((uint8_t *) &rss_key);
+#else
+       /* set up random bits */
+       cprng_fast(&rss_key, sizeof(rss_key));
+#endif
+
+       /* Set multiplier for RETA setup and table size based on MAC */
+       index_mult = 0x1;
+       table_size = 128;
+       switch (adapter->hw.mac.type) {
+       case ixgbe_mac_82598EB:
+               index_mult = 0x11;
+               break;
+       case ixgbe_mac_X550:
+       case ixgbe_mac_X550EM_x:
+               table_size = 512;
+               break;
+       default:
+               break;
+       }
+
+       /* Set up the redirection table */
+       for (int i = 0, j = 0; i < table_size; i++, j++) {
+               if (j == adapter->num_queues) j = 0;
+#ifdef RSS
+               /*
+                * Fetch the RSS bucket id for the given indirection entry.
+                * Cap it at the number of configured buckets (which is
+                * num_queues.)
+                */
+               queue_id = rss_get_indirection_to_bucket(i);
+               queue_id = queue_id % adapter->num_queues;
+#else
+               queue_id = (j * index_mult);
+#endif
+               /*
+                * The low 8 bits are for hash value (n+0);
+                * The next 8 bits are for hash value (n+1), etc.
+                */
+               reta = reta >> 8;
+               reta = reta | (((uint32_t) queue_id) << 24);
+               if ((i & 3) == 3) {
+                       if (i < 128)
+                               IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta);
+                       else
+                               IXGBE_WRITE_REG(hw, IXGBE_ERETA((i >> 2) - 32), reta);
+                       reta = 0;
+               }
+       }
+
+       /* Now fill our hash function seeds */
+       for (int i = 0; i < 10; i++)
+               IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), rss_key[i]);
+
+       /* Perform hash on these packet types */
+#ifdef RSS
+       mrqc = IXGBE_MRQC_RSSEN;
+       rss_hash_config = rss_gethashconfig();
+       if (rss_hash_config & RSS_HASHTYPE_RSS_IPV4)
+               mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4;
+       if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV4)
+               mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_TCP;
+       if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6)
+               mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6;
+       if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6)
+               mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_TCP;
+       if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6_EX)
+               mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_EX;
+       if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6_EX)
+               mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP;
+       if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4)
+               mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_UDP;
+       if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4_EX)
+               device_printf(adapter->dev,
+                   "%s: RSS_HASHTYPE_RSS_UDP_IPV4_EX defined, "
+                   "but not supported\n", __func__);
+       if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6)
+               mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP;
+       if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6_EX)
+               mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_EX_UDP;
+#else
+       /*
+        * Disable UDP - IP fragments aren't currently being handled
+        * and so we end up with a mix of 2-tuple and 4-tuple
+        * traffic.
+        */
+       mrqc = IXGBE_MRQC_RSSEN
+            | IXGBE_MRQC_RSS_FIELD_IPV4
+            | IXGBE_MRQC_RSS_FIELD_IPV4_TCP
+            | IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP
+            | IXGBE_MRQC_RSS_FIELD_IPV6_EX
+            | IXGBE_MRQC_RSS_FIELD_IPV6
+            | IXGBE_MRQC_RSS_FIELD_IPV6_TCP
+       ;
+#endif /* RSS */
+#ifdef PCI_IOV
+       mode = ixgbe_get_iov_mode(adapter);
+       mrqc |= ixgbe_get_mrqc(mode);
+#endif
+       IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc);
+}
+
+
 /*********************************************************************
- *  Device identification routine
- *
- *  ixgbe_probe determines if the driver should be loaded on
- *  adapter based on PCI vendor/device id of the adapter.
  *
- *  return 1 on success, 0 on failure
- *********************************************************************/
-
-static int
-ixgbe_probe(device_t dev, cfdata_t cf, void *aux)
-{
-       const struct pci_attach_args *pa = aux;
-
-       return (ixgbe_lookup(pa) != NULL) ? 1 : 0;
-}
-
-static ixgbe_vendor_info_t *
-ixgbe_lookup(const struct pci_attach_args *pa)
+ *  Setup receive registers and features.
+ *
+ **********************************************************************/
+#define IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT 2
+
+#define BSIZEPKT_ROUNDUP ((1<<IXGBE_SRRCTL_BSIZEPKT_SHIFT)-1)
+       
+static void
+ixgbe_initialize_receive_units(struct adapter *adapter)
 {
-       pcireg_t subid;
-       ixgbe_vendor_info_t *ent;
-
-       INIT_DEBUGOUT("ixgbe_lookup: begin");
-
-       if (PCI_VENDOR(pa->pa_id) != IXGBE_INTEL_VENDOR_ID)
-               return NULL;
-
-       subid = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
-
-       for (ent = ixgbe_vendor_info_array; ent->vendor_id != 0; ent++) {
-               if (PCI_VENDOR(pa->pa_id) == ent->vendor_id &&
-                   PCI_PRODUCT(pa->pa_id) == ent->device_id &&
-
-                   (PCI_SUBSYS_VENDOR(subid) == ent->subvendor_id ||
-                    ent->subvendor_id == 0) &&
-
-                   (PCI_SUBSYS_ID(subid) == ent->subdevice_id ||
-                    ent->subdevice_id == 0)) {
-                       ++ixgbe_total_ports;
-                       return ent;
+       int i;
+       struct  rx_ring *rxr = adapter->rx_rings;
+       struct ixgbe_hw *hw = &adapter->hw;
+       struct ifnet   *ifp = adapter->ifp;
+       u32             bufsz, fctrl, srrctl, rxcsum;
+       u32             hlreg;
+
+       /*
+        * Make sure receives are disabled while
+        * setting up the descriptor ring
+        */
+       ixgbe_disable_rx(hw);
+
+       /* Enable broadcasts */
+       fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
+       fctrl |= IXGBE_FCTRL_BAM;
+       if (adapter->hw.mac.type == ixgbe_mac_82598EB) {
+               fctrl |= IXGBE_FCTRL_DPF;
+               fctrl |= IXGBE_FCTRL_PMCF;
+       }
+       IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
+
+       /* Set for Jumbo Frames? */
+       hlreg = IXGBE_READ_REG(hw, IXGBE_HLREG0);
+       if (ifp->if_mtu > ETHERMTU)
+               hlreg |= IXGBE_HLREG0_JUMBOEN;
+       else
+               hlreg &= ~IXGBE_HLREG0_JUMBOEN;
+#ifdef DEV_NETMAP
+       /* crcstrip is conditional in netmap (in RDRXCTL too ?) */
+       if (ifp->if_capenable & IFCAP_NETMAP && !ix_crcstrip)
+               hlreg &= ~IXGBE_HLREG0_RXCRCSTRP;
+       else
+               hlreg |= IXGBE_HLREG0_RXCRCSTRP;
+#endif /* DEV_NETMAP */
+       IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg);
+
+       bufsz = (adapter->rx_mbuf_sz +
+           BSIZEPKT_ROUNDUP) >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
+
+       for (i = 0; i < adapter->num_queues; i++, rxr++) {
+               u64 rdba = rxr->rxdma.dma_paddr;
+               int j = rxr->me;
+               u32 tqsmreg, reg;
+               int regnum = i / 4;     /* 1 register per 4 queues */
+               int regshift = i % 4;   /* 4 bits per 1 queue */
+
+               /* Setup the Base and Length of the Rx Descriptor Ring */
+               IXGBE_WRITE_REG(hw, IXGBE_RDBAL(j),
+                   (rdba & 0x00000000ffffffffULL));
+               IXGBE_WRITE_REG(hw, IXGBE_RDBAH(j), (rdba >> 32));
+               IXGBE_WRITE_REG(hw, IXGBE_RDLEN(j),
+                   adapter->num_rx_desc * sizeof(union ixgbe_adv_rx_desc));
+
+               /* Set up the SRRCTL register */
+               srrctl = IXGBE_READ_REG(hw, IXGBE_SRRCTL(j));
+               srrctl &= ~IXGBE_SRRCTL_BSIZEHDR_MASK;
+               srrctl &= ~IXGBE_SRRCTL_BSIZEPKT_MASK;
+               srrctl |= bufsz;
+               srrctl |= IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF;
+
+               /* Set RQSMR (Receive Queue Statistic Mapping) register */
+               reg = IXGBE_READ_REG(hw, IXGBE_RQSMR(regnum));
+               reg &= ~(0x000000ff << (regshift * 8));
+               reg |= i << (regshift * 8);
+               IXGBE_WRITE_REG(hw, IXGBE_RQSMR(regnum), reg);
+
+               /*
+                * Set RQSMR (Receive Queue Statistic Mapping) register.
+                * Register location for queue 0...7 are different between
+                * 82598 and newer.
+                */
+               if (adapter->hw.mac.type == ixgbe_mac_82598EB)
+                       tqsmreg = IXGBE_TQSMR(regnum);
+               else
+                       tqsmreg = IXGBE_TQSM(regnum);
+               reg = IXGBE_READ_REG(hw, tqsmreg);
+               reg &= ~(0x000000ff << (regshift * 8));
+               reg |= i << (regshift * 8);
+               IXGBE_WRITE_REG(hw, tqsmreg, reg);
+
+               /*
+                * Set DROP_EN iff we have no flow control and >1 queue.
+                * Note that srrctl was cleared shortly before during reset,
+                * so we do not need to clear the bit, but do it just in case
+                * this code is moved elsewhere.
+                */
+               if (adapter->num_queues > 1 &&
+                   adapter->hw.fc.requested_mode == ixgbe_fc_none) {



Home | Main Index | Thread Index | Old Index