The branch main has been updated by np:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ba95b4aea78909bca972239afcbd51538c4b37c1

commit ba95b4aea78909bca972239afcbd51538c4b37c1
Author:     Navdeep Parhar <n...@freebsd.org>
AuthorDate: 2024-06-13 17:22:03 +0000
Commit:     Navdeep Parhar <n...@freebsd.org>
CommitDate: 2024-06-17 01:54:02 +0000

    cxgbe(4): New knob to limit driver to the specified types of doorbells.
    
    hw.cxgbe.doorbells_allowed="0xf"
    
    The adapter's doorbells bitmap is clipped to the value specified in the
    tunable, which is meant for debug and workarounds only.  There is no
    change in default behavior.
    
    MFC after:      1 week
    Sponsored by:   Chelsio Communications
---
 sys/dev/cxgbe/adapter.h |  1 +
 sys/dev/cxgbe/t4_main.c | 21 +++++++++++++++++++++
 sys/dev/cxgbe/t4_vf.c   |  4 ++++
 3 files changed, 26 insertions(+)

diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index 1a61834c5a40..9ab672ba6442 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -1364,6 +1364,7 @@ void t4_add_adapter(struct adapter *);
 int t4_detach_common(device_t);
 int t4_map_bars_0_and_4(struct adapter *);
 int t4_map_bar_2(struct adapter *);
+int t4_adj_doorbells(struct adapter *);
 int t4_setup_intr_handlers(struct adapter *);
 void t4_sysctls(struct adapter *);
 int begin_synchronized_op(struct adapter *, struct vi_info *, int, char *);
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index ae18efb25f15..96407e7ebaba 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -604,6 +604,11 @@ static int t5_write_combine = 0;
 SYSCTL_INT(_hw_cxl, OID_AUTO, write_combine, CTLFLAG_RDTUN, &t5_write_combine,
     0, "Use WC instead of UC for BAR2");
 
+/* From t4_sysctls: doorbells = {"\20\1UDB\2WCWR\3UDBWC\4KDB"} */
+static int t4_doorbells_allowed = 0xf;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, doorbells_allowed, CTLFLAG_RDTUN,
+          &t4_doorbells_allowed, 0, "Limit tx queues to these doorbells");
+
 static int t4_num_vis = 1;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, num_vis, CTLFLAG_RDTUN, &t4_num_vis, 0,
     "Number of VIs per port");
@@ -1347,6 +1352,10 @@ t4_attach(device_t dev)
        if (rc != 0)
                goto done; /* error message displayed already */
 
+       rc = t4_adj_doorbells(sc);
+       if (rc != 0)
+               goto done; /* error message displayed already */
+
        rc = t4_create_dma_tag(sc);
        if (rc != 0)
                goto done; /* error message displayed already */
@@ -3760,6 +3769,18 @@ t4_map_bar_2(struct adapter *sc)
        return (0);
 }
 
+int
+t4_adj_doorbells(struct adapter *sc)
+{
+       if ((sc->doorbells & t4_doorbells_allowed) != 0) {
+               sc->doorbells &= t4_doorbells_allowed;
+               return (0);
+       }
+       CH_ERR(sc, "No usable doorbell (available = 0x%x, allowed = 0x%x).\n",
+              sc->doorbells, t4_doorbells_allowed);
+       return (EINVAL);
+}
+
 struct memwin_init {
        uint32_t base;
        uint32_t aperture;
diff --git a/sys/dev/cxgbe/t4_vf.c b/sys/dev/cxgbe/t4_vf.c
index a4a611ed645c..24c80aaa7b2d 100644
--- a/sys/dev/cxgbe/t4_vf.c
+++ b/sys/dev/cxgbe/t4_vf.c
@@ -589,6 +589,10 @@ t4vf_attach(device_t dev)
        if (rc != 0)
                goto done; /* error message displayed already */
 
+       rc = t4_adj_doorbells(sc);
+       if (rc != 0)
+               goto done; /* error message displayed already */
+
        rc = t4_create_dma_tag(sc);
        if (rc != 0)
                goto done; /* error message displayed already */

Reply via email to