Author: jhb
Date: Mon Aug 15 17:40:05 2016
New Revision: 304168
URL: https://svnweb.freebsd.org/changeset/base/304168

Log:
  Make SGE parameter handling more VF-friendly.
  
  Add fields to hold the SGE control register and free list buffer sizes to
  the sge_params structure.  Populate these new fields in
  t4_init_sge_params() for PF devices and change t4_read_chip_settings() to
  pull these values out of the params structure instead of reading
  registers directly.  This will permit t4_read_chip_settings() to be reused
  for VF devices which cannot read SGE registers directly.
  
  While here, move the call to t4_init_sge_params() to
  get_params__post_init().  The VF driver will populate the SGE parameters
  structure via a different method before calling t4_read_chip_settings().
  
  Reviewed by:  np
  Sponsored by: Chelsio Communications
  Differential Revision:        https://reviews.freebsd.org/D7476

Modified:
  head/sys/dev/cxgbe/common/common.h
  head/sys/dev/cxgbe/common/t4_hw.c
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/common/common.h
==============================================================================
--- head/sys/dev/cxgbe/common/common.h  Mon Aug 15 17:37:28 2016        
(r304167)
+++ head/sys/dev/cxgbe/common/common.h  Mon Aug 15 17:40:05 2016        
(r304168)
@@ -215,6 +215,8 @@ struct sge_params {
        int pad_boundary;
        int pack_boundary;
        int fl_pktshift;
+       u32 sge_control;
+       u32 sge_fl_buffer_size[SGE_FLBUF_SIZES];
 };
 
 struct tp_params {

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==============================================================================
--- head/sys/dev/cxgbe/common/t4_hw.c   Mon Aug 15 17:37:28 2016        
(r304167)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Mon Aug 15 17:40:05 2016        
(r304168)
@@ -7644,6 +7644,7 @@ int t4_init_sge_params(struct adapter *a
 {
        u32 r;
        struct sge_params *sp = &adapter->params.sge;
+       unsigned i;
 
        r = t4_read_reg(adapter, A_SGE_INGRESS_RX_THRESHOLD);
        sp->counter_val[0] = G_THRESHOLD_0(r);
@@ -7686,6 +7687,7 @@ int t4_init_sge_params(struct adapter *a
        sp->page_shift = (r & M_HOSTPAGESIZEPF0) + 10;
 
        r = t4_read_reg(adapter, A_SGE_CONTROL);
+       sp->sge_control = r;
        sp->spg_len = r & F_EGRSTATUSPAGESIZE ? 128 : 64;
        sp->fl_pktshift = G_PKTSHIFT(r);
        sp->pad_boundary = 1 << (G_INGPADBOUNDARY(r) + 5);
@@ -7698,6 +7700,9 @@ int t4_init_sge_params(struct adapter *a
                else
                        sp->pack_boundary = 1 << (G_INGPACKBOUNDARY(r) + 5);
        }
+       for (i = 0; i < SGE_FLBUF_SIZES; i++)
+               sp->sge_fl_buffer_size[i] = t4_read_reg(adapter,
+                   A_SGE_FL_BUFFER_SIZE0 + (4 * i));
 
        return 0;
 }

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c        Mon Aug 15 17:37:28 2016        
(r304167)
+++ head/sys/dev/cxgbe/t4_main.c        Mon Aug 15 17:40:05 2016        
(r304168)
@@ -3332,6 +3332,8 @@ get_params__post_init(struct adapter *sc
                sc->vres.iscsi.size = val[1] - val[0] + 1;
        }
 
+       t4_init_sge_params(sc);
+
        /*
         * We've got the params we wanted to query via the firmware.  Now grab
         * some others directly from the chip.

Modified: head/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- head/sys/dev/cxgbe/t4_sge.c Mon Aug 15 17:37:28 2016        (r304167)
+++ head/sys/dev/cxgbe/t4_sge.c Mon Aug 15 17:40:05 2016        (r304168)
@@ -625,11 +625,9 @@ t4_read_chip_settings(struct adapter *sc
        struct sw_zone_info *swz, *safe_swz;
        struct hw_buf_info *hwb;
 
-       t4_init_sge_params(sc);
-
        m = F_RXPKTCPLMODE;
        v = F_RXPKTCPLMODE;
-       r = t4_read_reg(sc, A_SGE_CONTROL);
+       r = sc->params.sge.sge_control;
        if ((r & m) != v) {
                device_printf(sc->dev, "invalid SGE_CONTROL(0x%x)\n", r);
                rc = EINVAL;
@@ -647,7 +645,7 @@ t4_read_chip_settings(struct adapter *sc
        /* Filter out unusable hw buffer sizes entirely (mark with -2). */
        hwb = &s->hw_buf_info[0];
        for (i = 0; i < nitems(s->hw_buf_info); i++, hwb++) {
-               r = t4_read_reg(sc, A_SGE_FL_BUFFER_SIZE0 + (4 * i));
+               r = sc->params.sge.sge_fl_buffer_size[i];
                hwb->size = r;
                hwb->zidx = hwsz_ok(sc, r) ? -1 : -2;
                hwb->next = -1;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to