svn commit: r368557 - head/share/man/man9

2020-12-11 Thread Navdeep Parhar
Author: np
Date: Fri Dec 11 19:45:40 2020
New Revision: 368557
URL: https://svnweb.freebsd.org/changeset/base/368557

Log:
  vnet.9: Use correct location of vnet.h.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D27557

Modified:
  head/share/man/man9/vnet.9

Modified: head/share/man/man9/vnet.9
==
--- head/share/man/man9/vnet.9  Fri Dec 11 19:27:21 2020(r368556)
+++ head/share/man/man9/vnet.9  Fri Dec 11 19:45:40 2020(r368557)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 24, 2018
+.Dd December 10, 2020
 .Dt VNET 9
 .Os
 .Sh NAME
@@ -38,7 +38,7 @@
 .Cd "options VIMAGE"
 .Cd "options VNET_DEBUG"
 .Pp
-.In sys/vnet.h
+.In net/vnet.h
 .\"
 .Ss "Constants and Global Variables"
 .\"
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368315 - head/sys/dev/cxgbe

2020-12-03 Thread Navdeep Parhar
Author: np
Date: Thu Dec  3 22:04:23 2020
New Revision: 368315
URL: https://svnweb.freebsd.org/changeset/base/368315

Log:
  cxgbe(4): Fix vertical alignment in sysctl_cpl_stats.
  
  MFC after:3 days
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cThu Dec  3 22:01:13 2020
(r368314)
+++ head/sys/dev/cxgbe/t4_main.cThu Dec  3 22:04:23 2020
(r368315)
@@ -8269,13 +8269,13 @@ sysctl_cpl_stats(SYSCTL_HANDLER_ARGS)
"  channel 2  channel 3");
sbuf_printf(sb, "\nCPL requests:   %10u %10u %10u %10u",
stats.req[0], stats.req[1], stats.req[2], stats.req[3]);
-   sbuf_printf(sb, "\nCPL responses:   %10u %10u %10u %10u",
+   sbuf_printf(sb, "\nCPL responses:  %10u %10u %10u %10u",
stats.rsp[0], stats.rsp[1], stats.rsp[2], stats.rsp[3]);
} else {
sbuf_printf(sb, " channel 0  channel 1");
sbuf_printf(sb, "\nCPL requests:   %10u %10u",
stats.req[0], stats.req[1]);
-   sbuf_printf(sb, "\nCPL responses:   %10u %10u",
+   sbuf_printf(sb, "\nCPL responses:  %10u %10u",
stats.rsp[0], stats.rsp[1]);
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368313 - in head/sys/dev/cxgbe: . common

2020-12-03 Thread Navdeep Parhar
Author: np
Date: Thu Dec  3 22:00:41 2020
New Revision: 368313
URL: https://svnweb.freebsd.org/changeset/base/368313

Log:
  cxgbe(4): two new debug sysctls.
  
  dev...misc.tid_stats
  dev...misc.tnl_stats
  
  MFC after:3 days
  Sponsored by: Chelsio Communications

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

Modified: head/sys/dev/cxgbe/common/common.h
==
--- head/sys/dev/cxgbe/common/common.h  Thu Dec  3 21:59:47 2020
(r368312)
+++ head/sys/dev/cxgbe/common/common.h  Thu Dec  3 22:00:41 2020
(r368313)
@@ -189,6 +189,13 @@ struct tp_usm_stats {
u64 octets;
 };
 
+struct tp_tid_stats {
+   u32 del;
+   u32 inv;
+   u32 act;
+   u32 pas;
+};
+
 struct tp_fcoe_stats {
u32 frames_ddp;
u32 frames_drop;
@@ -208,6 +215,11 @@ struct tp_err_stats {
u32 ofld_cong_defer;
 };
 
+struct tp_tnl_stats {
+   u32 out_pkt[MAX_NCHAN];
+   u32 in_pkt[MAX_NCHAN];
+};
+
 struct tp_proxy_stats {
u32 proxy[MAX_NCHAN];
 };
@@ -715,6 +727,8 @@ void t4_tp_wr_bits_indirect(struct adapter *adap, unsi
 void t4_tp_read_la(struct adapter *adap, u64 *la_buf, unsigned int *wrptr);
 void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st,
 bool sleep_ok);
+void t4_tp_get_tnl_stats(struct adapter *adap, struct tp_tnl_stats *st,
+bool sleep_ok);
 void t4_tp_get_proxy_stats(struct adapter *adap, struct tp_proxy_stats *st,
   bool sleep_ok);
 void t4_tp_get_cpl_stats(struct adapter *adap, struct tp_cpl_stats *st,
@@ -722,6 +736,8 @@ void t4_tp_get_cpl_stats(struct adapter *adap, struct 
 void t4_tp_get_rdma_stats(struct adapter *adap, struct tp_rdma_stats *st,
  bool sleep_ok);
 void t4_get_usm_stats(struct adapter *adap, struct tp_usm_stats *st,
+ bool sleep_ok);
+void t4_tp_get_tid_stats(struct adapter *adap, struct tp_tid_stats *st,
  bool sleep_ok);
 void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
 struct tp_tcp_stats *v6, bool sleep_ok);

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Thu Dec  3 21:59:47 2020
(r368312)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Thu Dec  3 22:00:41 2020
(r368313)
@@ -6169,6 +6169,25 @@ void t4_tp_get_err_stats(struct adapter *adap, struct 
 }
 
 /**
+ * t4_tp_get_err_stats - read TP's error MIB counters
+ * @adap: the adapter
+ * @st: holds the counter values
+ * @sleep_ok: if true we may sleep while awaiting command completion
+ *
+ * Returns the values of TP's error counters.
+ */
+void t4_tp_get_tnl_stats(struct adapter *adap, struct tp_tnl_stats *st,
+bool sleep_ok)
+{
+   int nchan = adap->chip_params->nchan;
+
+   t4_tp_mib_read(adap, st->out_pkt, nchan, A_TP_MIB_TNL_OUT_PKT_0,
+  sleep_ok);
+   t4_tp_mib_read(adap, st->in_pkt, nchan, A_TP_MIB_TNL_IN_PKT_0,
+  sleep_ok);
+}
+
+/**
  * t4_tp_get_proxy_stats - read TP's proxy MIB counters
  * @adap: the adapter
  * @st: holds the counter values
@@ -6259,6 +6278,21 @@ void t4_get_usm_stats(struct adapter *adap, struct tp_
st->frames = val[0];
st->drops = val[1];
st->octets = ((u64)val[2] << 32) | val[3];
+}
+
+/**
+ * t4_tp_get_tid_stats - read TP's tid MIB counters.
+ * @adap: the adapter
+ * @st: holds the counter values
+ * @sleep_ok: if true we may sleep while awaiting command completion
+ *
+ * Returns the values of TP's counters for tids.
+ */
+void t4_tp_get_tid_stats(struct adapter *adap, struct tp_tid_stats *st,
+ bool sleep_ok)
+{
+
+   t4_tp_mib_read(adap, >del, 4, A_TP_MIB_TID_DEL, sleep_ok);
 }
 
 /**

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cThu Dec  3 21:59:47 2020
(r368312)
+++ head/sys/dev/cxgbe/t4_main.cThu Dec  3 22:00:41 2020
(r368313)
@@ -761,6 +761,7 @@ static int sysctl_cim_pif_la(SYSCTL_HANDLER_ARGS);
 static int sysctl_cim_qcfg(SYSCTL_HANDLER_ARGS);
 static int sysctl_cpl_stats(SYSCTL_HANDLER_ARGS);
 static int sysctl_ddp_stats(SYSCTL_HANDLER_ARGS);
+static int sysctl_tid_stats(SYSCTL_HANDLER_ARGS);
 static int sysctl_devlog(SYSCTL_HANDLER_ARGS);
 static int sysctl_fcoe_stats(SYSCTL_HANDLER_ARGS);
 static int sysctl_hw_sched(SYSCTL_HANDLER_ARGS);
@@ -775,6 +776,7 @@ static int sysctl_rdma_stats(SYSCTL_HANDLER_ARGS);
 static int sysctl_tcp_stats(SYSCTL_HANDLER_ARGS);
 static int sysctl_tids(SYSCTL_HANDLER_ARGS);
 static int sysctl_tp_err_stats(SYSCTL_HANDLER_ARGS);

svn commit: r368310 - head/share/man/man9

2020-12-03 Thread Navdeep Parhar
Author: np
Date: Thu Dec  3 21:38:00 2020
New Revision: 368310
URL: https://svnweb.freebsd.org/changeset/base/368310

Log:
  Fix typo in kern_testfrwk.9.

Modified:
  head/share/man/man9/kern_testfrwk.9

Modified: head/share/man/man9/kern_testfrwk.9
==
--- head/share/man/man9/kern_testfrwk.9 Thu Dec  3 19:29:18 2020
(r368309)
+++ head/share/man/man9/kern_testfrwk.9 Thu Dec  3 21:38:00 2020
(r368310)
@@ -30,7 +30,7 @@
 .Nm kern_testfrwk
 .Nd A kernel testing framework
 .Sh SYNOPSIS
-kld_load kern_testfrwk
+kldload kern_testfrwk
 .Sh DESCRIPTION
 .\" This whole section is not written in manual page style and should be ripped
 .\" out and replaced. -CEM
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368296 - in head/sys/dev/cxgbe: . common

2020-12-03 Thread Navdeep Parhar
Author: np
Date: Thu Dec  3 08:30:29 2020
New Revision: 368296
URL: https://svnweb.freebsd.org/changeset/base/368296

Log:
  cxgbe(4): Stop but don't free netmap queues when netmap is switched off.
  
  It is common for freelists to be starving when a netmap application
  stops.  Mailbox commands to free queues can hang in such a situation.
  Avoid that by not freeing the queues when netmap is switched off.
  Instead, use an alternate method to stop the queues without releasing
  the context ids.  If netmap is enabled again later then the same queue
  is reinitialized for use.  Move alloc_nm_rxq and txq to t4_netmap.c
  while here.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

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

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hThu Dec  3 05:56:42 2020
(r368295)
+++ head/sys/dev/cxgbe/adapter.hThu Dec  3 08:30:29 2020
(r368296)
@@ -1247,6 +1247,12 @@ struct sge_nm_rxq;
 void cxgbe_nm_attach(struct vi_info *);
 void cxgbe_nm_detach(struct vi_info *);
 void service_nm_rxq(struct sge_nm_rxq *);
+int alloc_nm_rxq(struct vi_info *, struct sge_nm_rxq *, int, int,
+struct sysctl_oid *);
+int free_nm_rxq(struct vi_info *, struct sge_nm_rxq *);
+int alloc_nm_txq(struct vi_info *, struct sge_nm_txq *, int, int,
+struct sysctl_oid *);
+int free_nm_txq(struct vi_info *, struct sge_nm_txq *);
 #endif
 
 /* t4_sge.c */
@@ -1259,6 +1265,11 @@ int t4_create_dma_tag(struct adapter *);
 void t4_sge_sysctls(struct adapter *, struct sysctl_ctx_list *,
 struct sysctl_oid_list *);
 int t4_destroy_dma_tag(struct adapter *);
+int alloc_ring(struct adapter *, size_t, bus_dma_tag_t *, bus_dmamap_t *,
+bus_addr_t *, void **);
+int free_ring(struct adapter *, bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
+void *);
+int sysctl_uint16(SYSCTL_HANDLER_ARGS);
 int t4_setup_adapter_queues(struct adapter *);
 int t4_teardown_adapter_queues(struct adapter *);
 int t4_setup_vi_queues(struct vi_info *);

Modified: head/sys/dev/cxgbe/common/common.h
==
--- head/sys/dev/cxgbe/common/common.h  Thu Dec  3 05:56:42 2020
(r368295)
+++ head/sys/dev/cxgbe/common/common.h  Thu Dec  3 08:30:29 2020
(r368296)
@@ -840,6 +840,8 @@ int t4_iq_stop(struct adapter *adap, unsigned int mbox
 int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
   unsigned int vf, unsigned int iqtype, unsigned int iqid,
   unsigned int fl0id, unsigned int fl1id);
+int t4_eth_eq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf,
+   unsigned int vf, unsigned int eqid);
 int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
   unsigned int vf, unsigned int eqid);
 int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Thu Dec  3 05:56:42 2020
(r368295)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Thu Dec  3 08:30:29 2020
(r368296)
@@ -8620,6 +8620,32 @@ int t4_iq_free(struct adapter *adap, unsigned int mbox
 }
 
 /**
+ * t4_eth_eq_stop - stop an Ethernet egress queue
+ * @adap: the adapter
+ * @mbox: mailbox to use for the FW command
+ * @pf: the PF owning the queues
+ * @vf: the VF owning the queues
+ * @eqid: egress queue id
+ *
+ * Stops an Ethernet egress queue.  The queue can be reinitialized or
+ * freed but is not otherwise functional after this call.
+ */
+int t4_eth_eq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf,
+   unsigned int vf, unsigned int eqid)
+{
+   struct fw_eq_eth_cmd c;
+
+   memset(, 0, sizeof(c));
+   c.op_to_vfn = cpu_to_be32(V_FW_CMD_OP(FW_EQ_ETH_CMD) |
+ F_FW_CMD_REQUEST | F_FW_CMD_EXEC |
+ V_FW_EQ_ETH_CMD_PFN(pf) |
+ V_FW_EQ_ETH_CMD_VFN(vf));
+   c.alloc_to_len16 = cpu_to_be32(F_FW_EQ_ETH_CMD_EQSTOP | FW_LEN16(c));
+   c.eqid_pkd = cpu_to_be32(V_FW_EQ_ETH_CMD_EQID(eqid));
+   return t4_wr_mbox(adap, mbox, , sizeof(c), NULL);
+}
+
+/**
  * t4_eth_eq_free - free an Ethernet egress queue
  * @adap: the adapter
  * @mbox: mailbox to use for the FW command

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Thu Dec  3 05:56:42 2020
(r368295)
+++ head/sys/dev/cxgbe/t4_netmap.c  Thu Dec  3 08:30:29 2020

svn commit: r368283 - head/sys/dev/cxgbe

2020-12-02 Thread Navdeep Parhar
Author: np
Date: Wed Dec  2 20:54:03 2020
New Revision: 368283
URL: https://svnweb.freebsd.org/changeset/base/368283

Log:
  cxgbe(4): Revert r367917.
  
  r367917 fixed the backpressure on the netmap rxq being stopped but that
  doesn't help if some other netmap rxq is starved (because it is stopping
  too although the driver doesn't know this yet) and blocks the pipeline.
  An alternate fix that works in all cases will be checked in instead.
  
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/t4_netmap.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hWed Dec  2 19:58:50 2020
(r368282)
+++ head/sys/dev/cxgbe/adapter.hWed Dec  2 20:54:03 2020
(r368283)
@@ -749,9 +749,6 @@ struct sge_nm_rxq {
bus_dma_tag_t fl_desc_tag;
bus_dmamap_t fl_desc_map;
bus_addr_t fl_ba;
-
-   void *bb;   /* bit bucket for packets with nowhere to go. */
-   uma_zone_t bb_zone;
 };
 
 #define INVALID_NM_TXQ_CNTXT_ID ((u_int)(-1))

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Wed Dec  2 19:58:50 2020
(r368282)
+++ head/sys/dev/cxgbe/t4_netmap.c  Wed Dec  2 20:54:03 2020
(r368283)
@@ -42,8 +42,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -588,8 +586,6 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi
 
alloc_nm_rxq_hwq(vi, nm_rxq, tnl_cong(vi->pi, nm_cong_drop));
nm_rxq->fl_hwidx = hwidx;
-   nm_rxq->bb_zone = rxb->zone;
-   nm_rxq->bb = uma_zalloc(nm_rxq->bb_zone, M_WAITOK);
slot = netmap_reset(na, NR_RX, i, 0);
MPASS(slot != NULL);/* XXXNM: error check, not assert */
 
@@ -632,31 +628,6 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi
return (cxgbe_netmap_rss(sc, vi, ifp, na));
 }
 
-static void
-flush_nm_rxq(struct adapter *sc, struct vi_info *vi, struct sge_nm_rxq *nm_rxq)
-{
-   int i, n;
-   u_int fl_pidx, fl_pidx_target, hw_cidx_desc;
-   const uint64_t ba = pmap_kextract((vm_offset_t)nm_rxq->bb);
-
-   hw_cidx_desc = nm_rxq->fl_cidx / 8;
-   if (hw_cidx_desc == 0)
-   fl_pidx_target = nm_rxq->fl_sidx2 - 8;
-   else
-   fl_pidx_target = (hw_cidx_desc - 1) * 8;
-   MPASS((fl_pidx_target & 7) == 0);
-
-   fl_pidx = nm_rxq->fl_pidx;
-   MPASS((fl_pidx & 7) == 0);
-   for (n = 0; fl_pidx != fl_pidx_target; n++) {
-   for (i = 0; i < 8; i++, fl_pidx++)
-   nm_rxq->fl_desc[fl_pidx] = htobe64(ba | 
nm_rxq->fl_hwidx);
-   if (__predict_false(fl_pidx == nm_rxq->fl_sidx2))
-   fl_pidx = 0;
-   }
-   t4_write_reg(sc, sc->sge_kdoorbell_reg, nm_rxq->fl_db_val | V_PIDX(n));
-}
-
 static int
 cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp,
 struct netmap_adapter *na)
@@ -681,23 +652,6 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *v
if (rc != 0)
return (rc);/* error message logged already. */
 
-   /*
-* First pass over the rx queues to make sure they're all caught up.
-*
-* The freelists could be out of buffers and we may need to arrange
-* things so that any packets still in flight (after TP's cong_drop
-* logic but not yet DMA'd) have somewhere to go and do not block the
-* pipeline.  Do this before trying to free any queue.
-*/
-   for_each_nm_rxq(vi, i, nm_rxq) {
-   nm_state = atomic_load_int(_rxq->nm_state);
-   kring = na->rx_rings[nm_rxq->nid];
-   if (nm_state == NM_OFF || !nm_kring_pending_off(kring))
-   continue;
-   MPASS(nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID);
-   flush_nm_rxq(sc, vi, nm_rxq);
-   }
-
for_each_nm_txq(vi, i, nm_txq) {
struct sge_qstat *spg = (void *)_txq->desc[nm_txq->sidx];
 
@@ -734,8 +688,6 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *v
pause("nmst", 1);
 
free_nm_rxq_hwq(vi, nm_rxq);
-   uma_zfree(nm_rxq->bb_zone, nm_rxq->bb);
-   nm_rxq->bb = NULL;
 
/* XXX: netmap, not the driver, should do this. */
kring->rhead = kring->rcur = kring->nr_hwcur = 0;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367973 - in stable/12/sys/dev/cxgbe: . common

2020-11-23 Thread Navdeep Parhar
Author: np
Date: Tue Nov 24 00:27:21 2020
New Revision: 367973
URL: https://svnweb.freebsd.org/changeset/base/367973

Log:
  MFC r367502:
  
  cxgbe(4): Allow the PF driver to set a VF's MAC address.
  
  The MAC address can be set with the optional mac-addr property in the VF
  section of the iovctl.conf(5) used to instantiate the VFs.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/common/common.h
  stable/12/sys/dev/cxgbe/common/t4_hw.c
  stable/12/sys/dev/cxgbe/t4_iov.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/common/common.h
==
--- stable/12/sys/dev/cxgbe/common/common.h Tue Nov 24 00:25:03 2020
(r367972)
+++ stable/12/sys/dev/cxgbe/common/common.h Tue Nov 24 00:27:21 2020
(r367973)
@@ -691,6 +691,8 @@ void t4_idma_monitor_init(struct adapter *adapter,
 void t4_idma_monitor(struct adapter *adapter,
 struct sge_idma_monitor_state *idma,
 int hz, int ticks);
+int t4_set_vf_mac(struct adapter *adapter, unsigned int pf, unsigned int vf,
+ unsigned int naddr, u8 *addr);
 
 unsigned int t4_get_regs_len(struct adapter *adapter);
 void t4_get_regs(struct adapter *adap, u8 *buf, size_t buf_size);

Modified: stable/12/sys/dev/cxgbe/common/t4_hw.c
==
--- stable/12/sys/dev/cxgbe/common/t4_hw.c  Tue Nov 24 00:25:03 2020
(r367972)
+++ stable/12/sys/dev/cxgbe/common/t4_hw.c  Tue Nov 24 00:27:21 2020
(r367973)
@@ -10202,6 +10202,48 @@ void t4_idma_monitor(struct adapter *adapter,
 }
 
 /**
+ * t4_set_vf_mac - Set MAC address for the specified VF
+ * @adapter: The adapter
+ * @pf: the PF used to instantiate the VFs
+ * @vf: one of the VFs instantiated by the specified PF
+ * @naddr: the number of MAC addresses
+ * @addr: the MAC address(es) to be set to the specified VF
+ */
+int t4_set_vf_mac(struct adapter *adapter, unsigned int pf, unsigned int vf,
+ unsigned int naddr, u8 *addr)
+{
+   struct fw_acl_mac_cmd cmd;
+
+   memset(, 0, sizeof(cmd));
+   cmd.op_to_vfn = cpu_to_be32(V_FW_CMD_OP(FW_ACL_MAC_CMD) |
+   F_FW_CMD_REQUEST |
+   F_FW_CMD_WRITE |
+   V_FW_ACL_MAC_CMD_PFN(pf) |
+   V_FW_ACL_MAC_CMD_VFN(vf));
+
+   /* Note: Do not enable the ACL */
+   cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
+   cmd.nmac = naddr;
+
+   switch (pf) {
+   case 3:
+   memcpy(cmd.macaddr3, addr, sizeof(cmd.macaddr3));
+   break;
+   case 2:
+   memcpy(cmd.macaddr2, addr, sizeof(cmd.macaddr2));
+   break;
+   case 1:
+   memcpy(cmd.macaddr1, addr, sizeof(cmd.macaddr1));
+   break;
+   case 0:
+   memcpy(cmd.macaddr0, addr, sizeof(cmd.macaddr0));
+   break;
+   }
+
+   return t4_wr_mbox(adapter, adapter->mbox, , sizeof(cmd), );
+}
+
+/**
  * t4_read_pace_tbl - read the pace table
  * @adap: the adapter
  * @pace_vals: holds the returned values

Modified: stable/12/sys/dev/cxgbe/t4_iov.c
==
--- stable/12/sys/dev/cxgbe/t4_iov.cTue Nov 24 00:25:03 2020
(r367972)
+++ stable/12/sys/dev/cxgbe/t4_iov.cTue Nov 24 00:27:21 2020
(r367973)
@@ -42,12 +42,19 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "common/common.h"
+#include "common/t4_regs.h"
 #include "t4_if.h"
 
 struct t4iov_softc {
device_t sc_dev;
device_t sc_main;
bool sc_attached;
+
+   int pf;
+   int regs_rid;
+   struct resource *regs_res;
+   bus_space_handle_t bh;
+   bus_space_tag_t bt;
 };
 
 struct {
@@ -113,6 +120,13 @@ struct {
{0x6087, "Chelsio T6225-CR 87"},
 };
 
+static inline uint32_t
+t4iov_read_reg(struct t4iov_softc *sc, uint32_t reg)
+{
+
+   return bus_space_read_4(sc->bt, sc->bh, reg);
+}
+
 static int t4iov_attach_child(device_t dev);
 
 static int
@@ -179,10 +193,28 @@ static int
 t4iov_attach(device_t dev)
 {
struct t4iov_softc *sc;
+   uint32_t pl_rev, whoami;
 
sc = device_get_softc(dev);
sc->sc_dev = dev;
 
+   sc->regs_rid = PCIR_BAR(0);
+   sc->regs_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+   >regs_rid, RF_ACTIVE);
+   if (sc->regs_res == NULL) {
+   device_printf(dev, "cannot map registers.\n");
+   return (ENXIO);
+   }
+   sc->bt = rman_get_bustag(sc->regs_res);
+   sc->bh = rman_get_bushandle(sc->regs_res);
+
+   pl_rev = t4iov_read_reg(sc, A_PL_REV);
+   whoami = t4iov_read_reg(sc, A_PL_WHOAMI);
+   if (G_CHIPID(pl_rev) <= 

svn commit: r367972 - in stable/12/sys/dev/cxgbe: . common

2020-11-23 Thread Navdeep Parhar
Author: np
Date: Tue Nov 24 00:25:03 2020
New Revision: 367972
URL: https://svnweb.freebsd.org/changeset/base/367972

Log:
  MFC r367497:
  
  cxgbev(4): Use the MAC address set by the the PF if there is one.
  
  Query the firmware for the MAC address set by the PF for the VF and use
  it instead of the firmware generated MAC if it's available.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/common/common.h
  stable/12/sys/dev/cxgbe/common/t4vf_hw.c
  stable/12/sys/dev/cxgbe/t4_vf.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/common/common.h
==
--- stable/12/sys/dev/cxgbe/common/common.h Tue Nov 24 00:22:33 2020
(r367971)
+++ stable/12/sys/dev/cxgbe/common/common.h Tue Nov 24 00:25:03 2020
(r367972)
@@ -912,6 +912,8 @@ int t4vf_get_sge_params(struct adapter *adapter);
 int t4vf_get_rss_glb_config(struct adapter *adapter);
 int t4vf_get_vfres(struct adapter *adapter);
 int t4vf_prep_adapter(struct adapter *adapter);
+int t4vf_get_vf_mac(struct adapter *adapter, unsigned int port,
+   unsigned int *naddr, u8 *addr);
 int t4_bar2_sge_qregs(struct adapter *adapter, unsigned int qid,
enum t4_bar2_qtype qtype, int user, u64 *pbar2_qoffset,
unsigned int *pbar2_qid);

Modified: stable/12/sys/dev/cxgbe/common/t4vf_hw.c
==
--- stable/12/sys/dev/cxgbe/common/t4vf_hw.cTue Nov 24 00:22:33 2020
(r367971)
+++ stable/12/sys/dev/cxgbe/common/t4vf_hw.cTue Nov 24 00:25:03 2020
(r367972)
@@ -382,3 +382,49 @@ int t4vf_prep_adapter(struct adapter *adapter)
 
return 0;
 }
+
+/*
+ * t4vf_get_vf_mac - Get the MAC address to be set to the VI of this VF.
+ * @adapter: The adapter
+ * @port: The port associated with vf
+ * @naddr: the number of ACL MAC addresses returned in addr
+ * @addr: Placeholder for MAC addresses
+ *
+ * Find the MAC address to be set to the VF's VI. The requested MAC address
+ * is from the host OS via callback in the PF driver.
+ */
+int t4vf_get_vf_mac(struct adapter *adapter, unsigned int port,
+   unsigned int *naddr, u8 *addr)
+{
+   struct fw_acl_mac_cmd cmd;
+   int ret;
+
+   memset(, 0, sizeof(cmd));
+   cmd.op_to_vfn = cpu_to_be32(V_FW_CMD_OP(FW_ACL_MAC_CMD) |
+ F_FW_CMD_REQUEST |
+ F_FW_CMD_READ);
+   cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
+   ret = t4vf_wr_mbox(adapter, , sizeof(cmd), );
+   if (ret)
+   return ret;
+
+   if (cmd.nmac < *naddr)
+   *naddr = cmd.nmac;
+
+   switch (port) {
+   case 3:
+   memcpy(addr, cmd.macaddr3, sizeof(cmd.macaddr3));
+   break;
+   case 2:
+   memcpy(addr, cmd.macaddr2, sizeof(cmd.macaddr2));
+   break;
+   case 1:
+   memcpy(addr, cmd.macaddr1, sizeof(cmd.macaddr1));
+   break;
+   case 0:
+   memcpy(addr, cmd.macaddr0, sizeof(cmd.macaddr0));
+   break;
+   }
+
+   return ret;
+}

Modified: stable/12/sys/dev/cxgbe/t4_vf.c
==
--- stable/12/sys/dev/cxgbe/t4_vf.c Tue Nov 24 00:22:33 2020
(r367971)
+++ stable/12/sys/dev/cxgbe/t4_vf.c Tue Nov 24 00:25:03 2020
(r367972)
@@ -481,7 +481,7 @@ static int
 t4vf_attach(device_t dev)
 {
struct adapter *sc;
-   int rc = 0, i, j, rqidx, tqidx;
+   int rc = 0, i, j, rqidx, tqidx, n, p, pmask;
struct make_dev_args mda;
struct intrs_and_queues iaq;
struct sge *s;
@@ -618,8 +618,10 @@ t4vf_attach(device_t dev)
 * First pass over all the ports - allocate VIs and initialize some
 * basic parameters like mac address, port type, etc.
 */
+   pmask = sc->params.vfres.pmask;
for_each_port(sc, i) {
struct port_info *pi;
+   uint8_t mac[ETHER_ADDR_LEN];
 
pi = malloc(sizeof(*pi), M_CXGBE, M_ZERO | M_WAITOK);
sc->port[i] = pi;
@@ -644,6 +646,15 @@ t4vf_attach(device_t dev)
sc->port[i] = NULL;
goto done;
}
+
+   /* Prefer the MAC address set by the PF, if there is one. */
+   n = 1;
+   p = ffs(pmask) - 1;
+   MPASS(p >= 0);
+   rc = t4vf_get_vf_mac(sc, p, , mac);
+   if (rc == 0 && n == 1)
+   t4_os_set_hw_addr(pi, mac);
+   pmask &= ~(1 << p);
 
/* No t4_link_start. */
 
___
svn-src-all@freebsd.org mailing list

svn commit: r367971 - in stable/12/sys: conf dev/cxgbe/firmware modules/cxgbe/t4_firmware modules/cxgbe/t5_firmware modules/cxgbe/t6_firmware

2020-11-23 Thread Navdeep Parhar
Author: np
Date: Tue Nov 24 00:22:33 2020
New Revision: 367971
URL: https://svnweb.freebsd.org/changeset/base/367971

Log:
  MFC r367428 and r367495.
  
  r367428:
  cxgbe(4):  Update firmwares to 1.25.0.40.
  
  This fixes a potential crash in firmware 1.25.0.0 on the passive open
  side during TOE operation.
  
  r367495:
  cxgbe(4): Add the firmware binaries missing in r367428.
  
  Obtained from:Chelsio Communications
  Sponsored by: Chelsio Communications

Added:
  stable/12/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin   (contents, props 
changed)
 - copied, changed from r367428, 
head/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin
  stable/12/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin   (contents, props 
changed)
 - copied, changed from r367428, 
head/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin
  stable/12/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin   (contents, props 
changed)
 - copied, changed from r367428, 
head/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin
Deleted:
  stable/12/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin
  stable/12/sys/dev/cxgbe/firmware/t5fw-1.25.0.0.bin
  stable/12/sys/dev/cxgbe/firmware/t6fw-1.25.0.0.bin
Modified:
  stable/12/sys/conf/files
  stable/12/sys/dev/cxgbe/firmware/t4fw_interface.h
  stable/12/sys/modules/cxgbe/t4_firmware/Makefile
  stable/12/sys/modules/cxgbe/t5_firmware/Makefile
  stable/12/sys/modules/cxgbe/t6_firmware/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/conf/files
==
--- stable/12/sys/conf/filesTue Nov 24 00:17:05 2020(r367970)
+++ stable/12/sys/conf/filesTue Nov 24 00:22:33 2020(r367971)
@@ -1476,7 +1476,7 @@ t4fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t4fw.fwo"
 t4fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t4fw-1.25.0.0.bin"   \
+   dependency  "$S/dev/cxgbe/firmware/t4fw-1.25.0.40.bin"  \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t4fw.fw"
@@ -1510,7 +1510,7 @@ t5fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t5fw.fwo"
 t5fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t5fw-1.25.0.0.bin"   \
+   dependency  "$S/dev/cxgbe/firmware/t5fw-1.25.0.40.bin"  \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t5fw.fw"
@@ -1544,7 +1544,7 @@ t6fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t6fw.fwo"
 t6fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t6fw-1.25.0.0.bin"   \
+   dependency  "$S/dev/cxgbe/firmware/t6fw-1.25.0.40.bin"  \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t6fw.fw"

Copied and modified: stable/12/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin (from 
r367428, head/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin)
==
Binary file (source and/or target). No diff available.

Modified: stable/12/sys/dev/cxgbe/firmware/t4fw_interface.h
==
--- stable/12/sys/dev/cxgbe/firmware/t4fw_interface.h   Tue Nov 24 00:17:05 
2020(r367970)
+++ stable/12/sys/dev/cxgbe/firmware/t4fw_interface.h   Tue Nov 24 00:22:33 
2020(r367971)
@@ -9985,17 +9985,17 @@ enum {
T4FW_VERSION_MAJOR  = 1,
T4FW_VERSION_MINOR  = 25,
T4FW_VERSION_MICRO  = 0,
-   T4FW_VERSION_BUILD  = 0,
+   T4FW_VERSION_BUILD  = 40,
 
T5FW_VERSION_MAJOR  = 1,
T5FW_VERSION_MINOR  = 25,
T5FW_VERSION_MICRO  = 0,
-   T5FW_VERSION_BUILD  = 0,
+   T5FW_VERSION_BUILD  = 40,
 
T6FW_VERSION_MAJOR  = 1,
T6FW_VERSION_MINOR  = 25,
T6FW_VERSION_MICRO  = 0,
-   T6FW_VERSION_BUILD  = 0,
+   T6FW_VERSION_BUILD  = 40,
 };
 
 enum {

Copied and modified: stable/12/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin (from 
r367428, head/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin)
==
Binary file 

svn commit: r367970 - stable/12/sys/dev/cxgbe

2020-11-23 Thread Navdeep Parhar
Author: np
Date: Tue Nov 24 00:17:05 2020
New Revision: 367970
URL: https://svnweb.freebsd.org/changeset/base/367970

Log:
  MFC r366929 and r367608.
  
  r366929:
  cxgbe(4): fix the size of the iq/eq maps.
  
  The firmware can allocate ingress and egress context ids anywhere from
  its configured range.  Size the iq/eq maps to match the entire range
  instead of assuming that the firmware always allocates the first
  available context id.
  
  Reported by:  Baptiste Wicht @ Verisign
  
  r367608:
  cxgbev(4): Make sure that the iq/eq map sizes are correct for VFs.
  
  This should have been part of r366929.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/t4_main.c
  stable/12/sys/dev/cxgbe/t4_netmap.c
  stable/12/sys/dev/cxgbe/t4_sge.c
  stable/12/sys/dev/cxgbe/t4_vf.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Tue Nov 24 00:12:42 2020
(r367969)
+++ stable/12/sys/dev/cxgbe/adapter.h   Tue Nov 24 00:17:05 2020
(r367970)
@@ -785,6 +785,8 @@ struct sge {
uint16_t iq_base;   /* first abs_id */
int eq_start;   /* first cntxt_id */
int eq_base;/* first abs_id */
+   int iqmap_sz;
+   int eqmap_sz;
struct sge_iq **iqmap;  /* iq->cntxt_id to iq mapping */
struct sge_eq **eqmap;  /* eq->cntxt_id to eq mapping */
 

Modified: stable/12/sys/dev/cxgbe/t4_main.c
==
--- stable/12/sys/dev/cxgbe/t4_main.c   Tue Nov 24 00:12:42 2020
(r367969)
+++ stable/12/sys/dev/cxgbe/t4_main.c   Tue Nov 24 00:17:05 2020
(r367970)
@@ -1311,6 +1311,8 @@ t4_attach(device_t dev)
s->nm_txq = malloc(s->nnmtxq * sizeof(struct sge_nm_txq),
M_CXGBE, M_ZERO | M_WAITOK);
 #endif
+   MPASS(s->niq <= s->iqmap_sz);
+   MPASS(s->neq <= s->eqmap_sz);
 
s->ctrlq = malloc(nports * sizeof(struct sge_wrq), M_CXGBE,
M_ZERO | M_WAITOK);
@@ -1318,9 +1320,9 @@ t4_attach(device_t dev)
M_ZERO | M_WAITOK);
s->txq = malloc(s->ntxq * sizeof(struct sge_txq), M_CXGBE,
M_ZERO | M_WAITOK);
-   s->iqmap = malloc(s->niq * sizeof(struct sge_iq *), M_CXGBE,
+   s->iqmap = malloc(s->iqmap_sz * sizeof(struct sge_iq *), M_CXGBE,
M_ZERO | M_WAITOK);
-   s->eqmap = malloc(s->neq * sizeof(struct sge_eq *), M_CXGBE,
+   s->eqmap = malloc(s->eqmap_sz * sizeof(struct sge_eq *), M_CXGBE,
M_ZERO | M_WAITOK);
 
sc->irq = malloc(sc->intr_count * sizeof(struct irq), M_CXGBE,
@@ -4298,6 +4300,19 @@ get_params__post_init(struct adapter *sc)
("%s: L2 table size (%u) larger than expected (%u)",
__func__, sc->vres.l2t.size, L2T_SIZE));
sc->params.core_vdd = val[6];
+
+   param[0] = FW_PARAM_PFVF(IQFLINT_END);
+   param[1] = FW_PARAM_PFVF(EQ_END);
+   rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val);
+   if (rc != 0) {
+   device_printf(sc->dev,
+   "failed to query parameters (post_init2): %d.\n", rc);
+   return (rc);
+   }
+   MPASS((int)val[0] >= sc->sge.iq_start);
+   sc->sge.iqmap_sz = val[0] - sc->sge.iq_start + 1;
+   MPASS((int)val[1] >= sc->sge.eq_start);
+   sc->sge.eqmap_sz = val[1] - sc->sge.eq_start + 1;
 
if (chip_id(sc) >= CHELSIO_T6) {
 

Modified: stable/12/sys/dev/cxgbe/t4_netmap.c
==
--- stable/12/sys/dev/cxgbe/t4_netmap.c Tue Nov 24 00:12:42 2020
(r367969)
+++ stable/12/sys/dev/cxgbe/t4_netmap.c Tue Nov 24 00:17:05 2020
(r367970)
@@ -188,9 +188,9 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq
nm_rxq->iq_cntxt_id = be16toh(c.iqid);
nm_rxq->iq_abs_id = be16toh(c.physiqid);
cntxt_id = nm_rxq->iq_cntxt_id - sc->sge.iq_start;
-   if (cntxt_id >= sc->sge.niq) {
+   if (cntxt_id >= sc->sge.iqmap_sz) {
panic ("%s: nm_rxq->iq_cntxt_id (%d) more than the max (%d)",
-   __func__, cntxt_id, sc->sge.niq - 1);
+   __func__, cntxt_id, sc->sge.iqmap_sz - 1);
}
sc->sge.iqmap[cntxt_id] = (void *)nm_rxq;
 
@@ -201,9 +201,9 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq
nm_rxq->fl_db_threshold = chip_id(sc) <= CHELSIO_T5 ? 8 : 4;
MPASS(nm_rxq->fl_sidx == na->num_rx_desc);
cntxt_id = nm_rxq->fl_cntxt_id - sc->sge.eq_start;
-   if (cntxt_id >= sc->sge.neq) {
+   if (cntxt_id >= sc->sge.eqmap_sz) {
panic("%s: nm_rxq->fl_cntxt_id (%d) more than the max (%d)",
-   __func__, cntxt_id, sc->sge.neq - 1);
+   __func__, cntxt_id, sc->sge.eqmap_sz - 

svn commit: r367969 - stable/12/sys/dev/cxgbe

2020-11-23 Thread Navdeep Parhar
Author: np
Date: Tue Nov 24 00:12:42 2020
New Revision: 367969
URL: https://svnweb.freebsd.org/changeset/base/367969

Log:
  MFC r366916:
  
  cxgbe(4): display correct tid range for T6 based -SO cards.
  
  Reported by:  Chelsio QA
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/t4_main.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/t4_main.c
==
--- stable/12/sys/dev/cxgbe/t4_main.c   Tue Nov 24 00:07:22 2020
(r367968)
+++ stable/12/sys/dev/cxgbe/t4_main.c   Tue Nov 24 00:12:42 2020
(r367969)
@@ -9020,8 +9020,10 @@ sysctl_tids(SYSCTL_HANDLER_ARGS)
if (b)
sbuf_printf(sb, "%u-%u, ", t->tid_base, b - 1);
sbuf_printf(sb, "%u-%u", hb, t->ntids - 1);
-   } else
-   sbuf_printf(sb, "%u-%u", t->tid_base, t->ntids - 1);
+   } else {
+   sbuf_printf(sb, "%u-%u", t->tid_base, t->tid_base +
+   t->ntids - 1);
+   }
sbuf_printf(sb, ", in use: %u\n",
atomic_load_acq_int(>tids_in_use));
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367968 - stable/12/sys/dev/cxgbe/common

2020-11-23 Thread Navdeep Parhar
Author: np
Date: Tue Nov 24 00:07:22 2020
New Revision: 367968
URL: https://svnweb.freebsd.org/changeset/base/367968

Log:
  MFC r366853:
  
  cxgbe(4): Fix page fault in t4_get_lb_stats with 2 port T5 cards.
  
  PR:   250449
  Reported by:  freqlabs@
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/common/t4_hw.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/common/t4_hw.c
==
--- stable/12/sys/dev/cxgbe/common/t4_hw.c  Tue Nov 24 00:02:14 2020
(r367967)
+++ stable/12/sys/dev/cxgbe/common/t4_hw.c  Tue Nov 24 00:07:22 2020
(r367968)
@@ -6957,7 +6957,6 @@ void t4_get_port_stats(struct adapter *adap, int idx, 
  */
 void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p)
 {
-   u32 bgmap = adap2pinfo(adap, idx)->mps_bg_map;
 
 #define GET_STAT(name) \
t4_read_reg64(adap, \
@@ -6982,14 +6981,18 @@ void t4_get_lb_stats(struct adapter *adap, int idx, st
p->frames_1519_max  = GET_STAT(1519B_MAX);
p->drop = GET_STAT(DROP_FRAMES);
 
-   p->ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_DROP_FRAME) : 0;
-   p->ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_DROP_FRAME) : 0;
-   p->ovflow2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_DROP_FRAME) : 0;
-   p->ovflow3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_DROP_FRAME) : 0;
-   p->trunc0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_TRUNC_FRAME) : 0;
-   p->trunc1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_TRUNC_FRAME) : 0;
-   p->trunc2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_TRUNC_FRAME) : 0;
-   p->trunc3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_TRUNC_FRAME) : 0;
+   if (idx < adap->params.nports) {
+   u32 bg = adap2pinfo(adap, idx)->mps_bg_map;
+
+   p->ovflow0 = (bg & 1) ? GET_STAT_COM(RX_BG_0_LB_DROP_FRAME) : 0;
+   p->ovflow1 = (bg & 2) ? GET_STAT_COM(RX_BG_1_LB_DROP_FRAME) : 0;
+   p->ovflow2 = (bg & 4) ? GET_STAT_COM(RX_BG_2_LB_DROP_FRAME) : 0;
+   p->ovflow3 = (bg & 8) ? GET_STAT_COM(RX_BG_3_LB_DROP_FRAME) : 0;
+   p->trunc0 = (bg & 1) ? GET_STAT_COM(RX_BG_0_LB_TRUNC_FRAME) : 0;
+   p->trunc1 = (bg & 2) ? GET_STAT_COM(RX_BG_1_LB_TRUNC_FRAME) : 0;
+   p->trunc2 = (bg & 4) ? GET_STAT_COM(RX_BG_2_LB_TRUNC_FRAME) : 0;
+   p->trunc3 = (bg & 8) ? GET_STAT_COM(RX_BG_3_LB_TRUNC_FRAME) : 0;
+   }
 
 #undef GET_STAT
 #undef GET_STAT_COM
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367967 - stable/12/sys/dev/cxgbe/common

2020-11-23 Thread Navdeep Parhar
Author: np
Date: Tue Nov 24 00:02:14 2020
New Revision: 367967
URL: https://svnweb.freebsd.org/changeset/base/367967

Log:
  MFC r366696:
  
  cxgbe(4): Do not request FEC when requesting speeds that don't have FEC.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/common/t4_hw.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/common/t4_hw.c
==
--- stable/12/sys/dev/cxgbe/common/t4_hw.c  Mon Nov 23 23:58:14 2020
(r367966)
+++ stable/12/sys/dev/cxgbe/common/t4_hw.c  Tue Nov 24 00:02:14 2020
(r367967)
@@ -3915,7 +3915,7 @@ int t4_link_l1cfg(struct adapter *adap, unsigned int m
speed = fwcap_top_speed(lc->pcaps);
 
fec = 0;
-   if (fec_supported(lc->pcaps)) {
+   if (fec_supported(speed)) {
if (lc->requested_fec == FEC_AUTO) {
if (lc->pcaps & FW_PORT_CAP32_FORCE_FEC) {
if (speed & FW_PORT_CAP32_SPEED_100G) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367966 - stable/12/sys/dev/cxgbe/cudbg

2020-11-23 Thread Navdeep Parhar
Author: np
Date: Mon Nov 23 23:58:14 2020
New Revision: 367966
URL: https://svnweb.freebsd.org/changeset/base/367966

Log:
  MFC r366694:
  
  cxgbe(4): unimplemented cudbg routines should return the correct
  internal error code and not an errno.
  
  Submitted by: Krishnamraju Eraparaju @ Chelsio
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/cudbg/cudbg_lib.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/cudbg/cudbg_lib.c
==
--- stable/12/sys/dev/cxgbe/cudbg/cudbg_lib.c   Mon Nov 23 23:53:21 2020
(r367965)
+++ stable/12/sys/dev/cxgbe/cudbg/cudbg_lib.c   Mon Nov 23 23:58:14 2020
(r367966)
@@ -2027,7 +2027,7 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
 /* CIM OBQ */
 
@@ -2664,7 +2664,7 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
 
 static void collect_mem_info(struct cudbg_init *pdbg_init,
@@ -3130,7 +3130,7 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
 
 static int collect_pbt_tables(struct cudbg_init *pdbg_init,
@@ -4450,5 +4450,5 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367965 - in stable/12: share/man/man4 sys/dev/cxgbe

2020-11-23 Thread Navdeep Parhar
Author: np
Date: Mon Nov 23 23:53:21 2020
New Revision: 367965
URL: https://svnweb.freebsd.org/changeset/base/367965

Log:
  MFC r366532 and r366862.
  
  r366532:
  cxgbe(4): knobs to drop various kinds of undesirable frames on ingress.
  
  These kind of drops come for free in the sense that they do not use the
  filter TCAM or any other resource that wouldn't normally be used during
  rx.  Frames dropped by the hardware get counted in the MAC's rx stats
  but are not delivered to the driver.
  
  hw.cxgbe.attack_filter
  Set to 1 to enable the "attack filter".  Default is 0.  The attack
  filter will drop an incoming frame if any of these conditions is true:
  src ip/ip6 == dst ip/ip6; tcp and src/dst ip is not unicast; src/dst ip
  is loopback (127.x.y.z); src ip6 is not unicast; src/dst ip6 is loopback
  (::1/128) or unspecified (::/128); tcp and src/dst ip6 is mcast
  (ff00::/8).
  
  hw.cxgbe.drop_ip_fragments
  Set to 1 to drop all incoming IP fragments.  Default is 0.  Note that
  this drops valid frames.
  
  hw.cxgbe.drop_pkts_with_l2_errors
  Set to 1 to drop incoming frames with Layer 2 length or checksum errors.
  Default is 1.
  
  hw.cxgbe.drop_pkts_with_l3_errors
  Set to 1 to drop incoming frames with IP version, length, or checksum
  errors.  Default is 0.
  
  hw.cxgbe.drop_pkts_with_l4_errors
  Set to 1 to drop incoming frames with Layer 4 length, checksum, or other
  errors.  Default is 0.
  
  r366862:
  cxgbe(4): Updates to the drop features from r366532.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/share/man/man4/cxgbe.4
  stable/12/sys/dev/cxgbe/t4_main.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/cxgbe.4
==
--- stable/12/share/man/man4/cxgbe.4Mon Nov 23 23:46:07 2020
(r367964)
+++ stable/12/share/man/man4/cxgbe.4Mon Nov 23 23:53:21 2020
(r367965)
@@ -31,7 +31,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 17, 2020
+.Dd October 19, 2020
 .Dt CXGBE 4
 .Os
 .Sh NAME
@@ -362,6 +362,29 @@ The default value is 0 and should be changed only if P
 to communicate with each other.
 Different interfaces can be assigned different values using the
 dev..X.tx_vm_wr sysctl when the interface is administratively down.
+.It Va hw.cxgbe.attack_filter
+Set to 1 to enable the "attack filter".
+Default is 0.
+The attack filter will drop an incoming frame if any of these conditions is
+true: src ip/ip6 == dst ip/ip6; tcp and src/dst ip is not unicast; src/dst ip 
is
+loopback (127.x.y.z); src ip6 is not unicast; src/dst ip6 is loopback (::1/128)
+or unspecified (::/128); tcp and src/dst ip6 is mcast (ff00::/8).
+This facility is available on T4 and T5 based cards only.
+.It Va hw.cxgbe.drop_ip_fragments
+Set to 1 to drop all incoming IP fragments.
+Default is 0.
+Note that this drops valid frames.
+.It Va hw.cxgbe.drop_pkts_with_l2_errors
+Set to 1 to drop incoming frames with Layer 2 length or checksum errors.
+Default is 1.
+.It Va hw.cxgbe.drop_pkts_with_l3_errors
+Set to 1 to drop incoming frames with IP version, length, or checksum errors.
+The IP checksum is validated for TCP or UDP packets only.
+Default is 0.
+.It Va hw.cxgbe.drop_pkts_with_l4_errors
+Set to 1 to drop incoming frames with Layer 4 (TCP or UDP) length,
+checksum, or other errors.
+Default is 0.
 .El
 .Sh SUPPORT
 For general information and support,

Modified: stable/12/sys/dev/cxgbe/t4_main.c
==
--- stable/12/sys/dev/cxgbe/t4_main.c   Mon Nov 23 23:46:07 2020
(r367964)
+++ stable/12/sys/dev/cxgbe/t4_main.c   Mon Nov 23 23:53:21 2020
(r367965)
@@ -579,6 +579,46 @@ static int t4_tx_vm_wr = 0;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, tx_vm_wr, CTLFLAG_RWTUN, _tx_vm_wr, 0,
 "Use VM work requests to transmit packets.");
 
+/*
+ * Set to non-zero to enable the attack filter.  A packet that matches any of
+ * these conditions will get dropped on ingress:
+ * 1) IP && source address == destination address.
+ * 2) TCP/IP && source address is not a unicast address.
+ * 3) TCP/IP && destination address is not a unicast address.
+ * 4) IP && source address is loopback (127.x.y.z).
+ * 5) IP && destination address is loopback (127.x.y.z).
+ * 6) IPv6 && source address == destination address.
+ * 7) IPv6 && source address is not a unicast address.
+ * 8) IPv6 && source address is loopback (::1/128).
+ * 9) IPv6 && destination address is loopback (::1/128).
+ * 10) IPv6 && source address is unspecified (::/128).
+ * 11) IPv6 && destination address is unspecified (::/128).
+ * 12) TCP/IPv6 && source address is multicast (ff00::/8).
+ * 13) TCP/IPv6 && destination address is multicast (ff00::/8).
+ */
+static int t4_attack_filter = 0;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, attack_filter, CTLFLAG_RDTUN,
+_attack_filter, 0, "Drop suspicious traffic");
+
+static int t4_drop_ip_fragments = 0;

svn commit: r367964 - in stable/12/sys/dev/cxgbe: . common

2020-11-23 Thread Navdeep Parhar
Author: np
Date: Mon Nov 23 23:46:07 2020
New Revision: 367964
URL: https://svnweb.freebsd.org/changeset/base/367964

Log:
  MFC r365732 and r366589.
  
  r365732:
  cxgbe(4): Get the count of FCS errors from the MAC and not MPS for T6 ports.
  
  The MPS register on the T6 counts something other than FCS errors despite its
  name.
  
  r366589:
  cxgbe(4): More fixes for the T6 FCS error counter.
  
  r365732 was the first attempt to get an accurate count but it was
  writing to some read-only registers to clear them and that obviously
  didn't work.  Instead, note the counter's value when it is supposed to
  be cleared and subtract it from future readings.
  
  dev..stats.rx_fcs_error should not be serviced from the MPS
  register for T6.
  
  The stats.* sysctls should all use T5_PORT_REG for T5 and above.  This
  must have been missed in the initial T5 support years ago.  Fix it while
  here.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/common/t4_hw.c
  stable/12/sys/dev/cxgbe/t4_main.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Mon Nov 23 18:37:19 2020
(r367963)
+++ stable/12/sys/dev/cxgbe/adapter.h   Mon Nov 23 23:46:07 2020
(r367964)
@@ -314,6 +314,8 @@ struct port_info {
struct port_stats stats;
u_int tnl_cong_drops;
u_int tx_parse_error;
+   int fcs_reg;
+   uint64_t fcs_base;
u_long  tx_toe_tls_records;
u_long  tx_toe_tls_octets;
u_long  rx_toe_tls_records;

Modified: stable/12/sys/dev/cxgbe/common/t4_hw.c
==
--- stable/12/sys/dev/cxgbe/common/t4_hw.c  Mon Nov 23 18:37:19 2020
(r367963)
+++ stable/12/sys/dev/cxgbe/common/t4_hw.c  Mon Nov 23 23:46:07 2020
(r367964)
@@ -6852,7 +6852,8 @@ void t4_get_port_stats_offset(struct adapter *adap, in
  */
 void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
 {
-   u32 bgmap = adap2pinfo(adap, idx)->mps_bg_map;
+   struct port_info *pi = adap->port[idx];
+   u32 bgmap = pi->mps_bg_map;
u32 stat_ctl = t4_read_reg(adap, A_MPS_STAT_CTL);
 
 #define GET_STAT(name) \
@@ -6902,7 +6903,6 @@ void t4_get_port_stats(struct adapter *adap, int idx, 
p->rx_ucast_frames  = GET_STAT(RX_PORT_UCAST);
p->rx_too_long  = GET_STAT(RX_PORT_MTU_ERROR);
p->rx_jabber= GET_STAT(RX_PORT_MTU_CRC_ERROR);
-   p->rx_fcs_err   = GET_STAT(RX_PORT_CRC_ERROR);
p->rx_len_err   = GET_STAT(RX_PORT_LEN_ERROR);
p->rx_symbol_err= GET_STAT(RX_PORT_SYM_ERROR);
p->rx_runt  = GET_STAT(RX_PORT_LESS_64B);
@@ -6921,6 +6921,9 @@ void t4_get_port_stats(struct adapter *adap, int idx, 
p->rx_ppp5  = GET_STAT(RX_PORT_PPP5);
p->rx_ppp6  = GET_STAT(RX_PORT_PPP6);
p->rx_ppp7  = GET_STAT(RX_PORT_PPP7);
+
+   if (pi->fcs_reg != -1)
+   p->rx_fcs_err = t4_read_reg64(adap, pi->fcs_reg) - pi->fcs_base;
 
if (chip_id(adap) >= CHELSIO_T5) {
if (stat_ctl & F_COUNTPAUSESTATRX) {

Modified: stable/12/sys/dev/cxgbe/t4_main.c
==
--- stable/12/sys/dev/cxgbe/t4_main.c   Mon Nov 23 18:37:19 2020
(r367963)
+++ stable/12/sys/dev/cxgbe/t4_main.c   Mon Nov 23 23:46:07 2020
(r367964)
@@ -1166,6 +1166,23 @@ t4_attach(device_t dev)
mtx_init(>pi_lock, pi->lockname, 0, MTX_DEF);
sc->chan_map[pi->tx_chan] = i;
 
+   /*
+* The MPS counter for FCS errors doesn't work correctly on the
+* T6 so we use the MAC counter here.  Which MAC is in use
+* depends on the link settings which will be known when the
+* link comes up.
+*/
+   if (is_t6(sc)) {
+   pi->fcs_reg = -1;
+   } else if (is_t4(sc)) {
+   pi->fcs_reg = PORT_REG(pi->tx_chan,
+   A_MPS_PORT_STAT_RX_PORT_CRC_ERROR_L);
+   } else {
+   pi->fcs_reg = T5_PORT_REG(pi->tx_chan,
+   A_MPS_PORT_STAT_RX_PORT_CRC_ERROR_L);
+   }
+   pi->fcs_base = 0;
+
/* All VIs on this port share this media. */
ifmedia_init(>media, IFM_IMASK, cxgbe_media_change,
cxgbe_media_status);
@@ -6677,155 +6694,88 @@ cxgbe_sysctls(struct port_info *pi)
>tx_parse_error, 0,
"# of tx packets with invalid length or # of segments");
 
-#define SYSCTL_ADD_T4_REG64(pi, name, desc, reg) \
-   

svn commit: r367917 - head/sys/dev/cxgbe

2020-11-20 Thread Navdeep Parhar
Author: np
Date: Sat Nov 21 03:27:32 2020
New Revision: 367917
URL: https://svnweb.freebsd.org/changeset/base/367917

Log:
  cxgbe(4): Catch up with in-flight netmap rx before destroying queues.
  
  The netmap application using the driver is responsible for replenishing
  the receive freelists and they may be totally depleted when the
  application exits.  Packets in flight, if any, might block the pipeline
  in case there aren't enough buffers left in the freelist.  Avoid this by
  filling up the freelists with a driver allocated buffer.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/t4_netmap.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hSat Nov 21 00:53:31 2020
(r367916)
+++ head/sys/dev/cxgbe/adapter.hSat Nov 21 03:27:32 2020
(r367917)
@@ -749,6 +749,9 @@ struct sge_nm_rxq {
bus_dma_tag_t fl_desc_tag;
bus_dmamap_t fl_desc_map;
bus_addr_t fl_ba;
+
+   void *bb;   /* bit bucket for packets with nowhere to go. */
+   uma_zone_t bb_zone;
 };
 
 #define INVALID_NM_TXQ_CNTXT_ID ((u_int)(-1))

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Sat Nov 21 00:53:31 2020
(r367916)
+++ head/sys/dev/cxgbe/t4_netmap.c  Sat Nov 21 03:27:32 2020
(r367917)
@@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -586,6 +588,8 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi
 
alloc_nm_rxq_hwq(vi, nm_rxq, tnl_cong(vi->pi, nm_cong_drop));
nm_rxq->fl_hwidx = hwidx;
+   nm_rxq->bb_zone = rxb->zone;
+   nm_rxq->bb = uma_zalloc(nm_rxq->bb_zone, M_WAITOK);
slot = netmap_reset(na, NR_RX, i, 0);
MPASS(slot != NULL);/* XXXNM: error check, not assert */
 
@@ -628,6 +632,31 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi
return (cxgbe_netmap_rss(sc, vi, ifp, na));
 }
 
+static void
+flush_nm_rxq(struct adapter *sc, struct vi_info *vi, struct sge_nm_rxq *nm_rxq)
+{
+   int i, n;
+   u_int fl_pidx, fl_pidx_target, hw_cidx_desc;
+   const uint64_t ba = pmap_kextract((vm_offset_t)nm_rxq->bb);
+
+   hw_cidx_desc = nm_rxq->fl_cidx / 8;
+   if (hw_cidx_desc == 0)
+   fl_pidx_target = nm_rxq->fl_sidx2 - 8;
+   else
+   fl_pidx_target = (hw_cidx_desc - 1) * 8;
+   MPASS((fl_pidx_target & 7) == 0);
+
+   fl_pidx = nm_rxq->fl_pidx;
+   MPASS((fl_pidx & 7) == 0);
+   for (n = 0; fl_pidx != fl_pidx_target; n++) {
+   for (i = 0; i < 8; i++, fl_pidx++)
+   nm_rxq->fl_desc[fl_pidx] = htobe64(ba | 
nm_rxq->fl_hwidx);
+   if (__predict_false(fl_pidx == nm_rxq->fl_sidx2))
+   fl_pidx = 0;
+   }
+   t4_write_reg(sc, sc->sge_kdoorbell_reg, nm_rxq->fl_db_val | V_PIDX(n));
+}
+
 static int
 cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp,
 struct netmap_adapter *na)
@@ -652,6 +681,23 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *v
if (rc != 0)
return (rc);/* error message logged already. */
 
+   /*
+* First pass over the rx queues to make sure they're all caught up.
+*
+* The freelists could be out of buffers and we may need to arrange
+* things so that any packets still in flight (after TP's cong_drop
+* logic but not yet DMA'd) have somewhere to go and do not block the
+* pipeline.  Do this before trying to free any queue.
+*/
+   for_each_nm_rxq(vi, i, nm_rxq) {
+   nm_state = atomic_load_int(_rxq->nm_state);
+   kring = na->rx_rings[nm_rxq->nid];
+   if (nm_state == NM_OFF || !nm_kring_pending_off(kring))
+   continue;
+   MPASS(nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID);
+   flush_nm_rxq(sc, vi, nm_rxq);
+   }
+
for_each_nm_txq(vi, i, nm_txq) {
struct sge_qstat *spg = (void *)_txq->desc[nm_txq->sidx];
 
@@ -688,6 +734,8 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *v
pause("nmst", 1);
 
free_nm_rxq_hwq(vi, nm_rxq);
+   uma_zfree(nm_rxq->bb_zone, nm_rxq->bb);
+   nm_rxq->bb = NULL;
 
/* XXX: netmap, not the driver, should do this. */
kring->rhead = kring->rcur = kring->nr_hwcur = 0;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367624 - head/sys/dev/cxgbe/tom

2020-11-12 Thread Navdeep Parhar
Author: np
Date: Thu Nov 12 20:02:48 2020
New Revision: 367624
URL: https://svnweb.freebsd.org/changeset/base/367624

Log:
  cxgbe/t4_tom: Handle VXLAN-encapsulated SYNs correctly.
  
  TCP SYNs in inner traffic will hit hardware listeners when VXLAN/NVGRE
  rx parsing is enabled in the chip.  t4_tom should pass on these SYNs to
  the kernel and let it deal with them as if they arrived on the non-TOE
  path.
  
  Reported by:  Sony at Chelsio
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/tom/t4_listen.c

Modified: head/sys/dev/cxgbe/tom/t4_listen.c
==
--- head/sys/dev/cxgbe/tom/t4_listen.c  Thu Nov 12 19:25:31 2020
(r367623)
+++ head/sys/dev/cxgbe/tom/t4_listen.c  Thu Nov 12 20:02:48 2020
(r367624)
@@ -1003,6 +1003,17 @@ t4opt_to_tcpopt(const struct tcp_options *t4opt, struc
to->to_flags |= TOF_SACKPERM;
 }
 
+static bool
+encapsulated_syn(struct adapter *sc, const struct cpl_pass_accept_req *cpl)
+{
+   u_int hlen = be32toh(cpl->hdr_len);
+
+   if (chip_id(sc) >= CHELSIO_T6)
+   return (G_T6_ETH_HDR_LEN(hlen) > sizeof(struct 
ether_vlan_header));
+   else
+   return (G_ETH_HDR_LEN(hlen) > sizeof(struct ether_vlan_header));
+}
+
 static void
 pass_accept_req_to_protohdrs(struct adapter *sc, const struct mbuf *m,
 struct in_conninfo *inc, struct tcphdr *th, uint8_t *iptos)
@@ -1194,22 +1205,38 @@ do_pass_accept_req(struct sge_iq *iq, const struct rss
CTR4(KTR_CXGBE, "%s: stid %u, tid %u, lctx %p", __func__, stid, tid,
lctx);
 
+   /*
+* Figure out the port the SYN arrived on.  We'll look for an exact VI
+* match in a bit but in case we don't find any we'll use the main VI as
+* the incoming ifnet.
+*/
+   l2info = be16toh(cpl->l2info);
+   pi = sc->port[G_SYN_INTF(l2info)];
+   hw_ifp = pi->vi[0].ifp;
+   m->m_pkthdr.rcvif = hw_ifp;
+
CURVNET_SET(lctx->vnet);/* before any potential REJECT */
 
/*
+* If VXLAN/NVGRE parsing is enabled then SYNs in the inner traffic will
+* also hit the listener.  We don't want to offload those.
+*/
+   if (encapsulated_syn(sc, cpl)) {
+   REJECT_PASS_ACCEPT_REQ(true);
+   }
+
+   /*
 * Use the MAC index to lookup the associated VI.  If this SYN didn't
 * match a perfect MAC filter, punt.
 */
-   l2info = be16toh(cpl->l2info);
-   pi = sc->port[G_SYN_INTF(l2info)];
if (!(l2info & F_SYN_XACT_MATCH)) {
-   REJECT_PASS_ACCEPT_REQ(false);
+   REJECT_PASS_ACCEPT_REQ(true);
}
for_each_vi(pi, v, vi) {
if (vi->xact_addr_filt == G_SYN_MAC_IDX(l2info))
goto found;
}
-   REJECT_PASS_ACCEPT_REQ(false);
+   REJECT_PASS_ACCEPT_REQ(true);
 found:
hw_ifp = vi->ifp;   /* the cxgbe ifnet */
m->m_pkthdr.rcvif = hw_ifp;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367608 - head/sys/dev/cxgbe

2020-11-11 Thread Navdeep Parhar
Author: np
Date: Thu Nov 12 01:18:05 2020
New Revision: 367608
URL: https://svnweb.freebsd.org/changeset/base/367608

Log:
  cxgbev(4): Make sure that the iq/eq map sizes are correct for VFs.
  
  This should have been part of r366929.
  
  MFC after:3 days
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_vf.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cThu Nov 12 00:51:53 2020
(r367607)
+++ head/sys/dev/cxgbe/t4_main.cThu Nov 12 01:18:05 2020
(r367608)
@@ -4467,9 +4467,9 @@ get_params__post_init(struct adapter *sc)
"failed to query parameters (post_init2): %d.\n", rc);
return (rc);
}
-   MPASS(val[0] >= sc->sge.iq_start);
+   MPASS((int)val[0] >= sc->sge.iq_start);
sc->sge.iqmap_sz = val[0] - sc->sge.iq_start + 1;
-   MPASS(val[1] >= sc->sge.eq_start);
+   MPASS((int)val[1] >= sc->sge.eq_start);
sc->sge.eqmap_sz = val[1] - sc->sge.eq_start + 1;
 
if (chip_id(sc) >= CHELSIO_T6) {

Modified: head/sys/dev/cxgbe/t4_vf.c
==
--- head/sys/dev/cxgbe/t4_vf.c  Thu Nov 12 00:51:53 2020(r367607)
+++ head/sys/dev/cxgbe/t4_vf.c  Thu Nov 12 01:18:05 2020(r367608)
@@ -695,13 +695,16 @@ t4vf_attach(device_t dev)
s->neq += sc->params.nports;/* ctrl queues: 1 per port */
s->niq = s->nrxq + 1;   /* 1 extra for firmware event queue */
 
+   s->iqmap_sz = s->niq;
+   s->eqmap_sz = s->neq;
+
s->rxq = malloc(s->nrxq * sizeof(struct sge_rxq), M_CXGBE,
M_ZERO | M_WAITOK);
s->txq = malloc(s->ntxq * sizeof(struct sge_txq), M_CXGBE,
M_ZERO | M_WAITOK);
-   s->iqmap = malloc(s->niq * sizeof(struct sge_iq *), M_CXGBE,
+   s->iqmap = malloc(s->iqmap_sz * sizeof(struct sge_iq *), M_CXGBE,
M_ZERO | M_WAITOK);
-   s->eqmap = malloc(s->neq * sizeof(struct sge_eq *), M_CXGBE,
+   s->eqmap = malloc(s->eqmap_sz * sizeof(struct sge_eq *), M_CXGBE,
M_ZERO | M_WAITOK);
 
sc->irq = malloc(sc->intr_count * sizeof(struct irq), M_CXGBE,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367502 - in head/sys/dev/cxgbe: . common

2020-11-08 Thread Navdeep Parhar
Author: np
Date: Mon Nov  9 00:08:35 2020
New Revision: 367502
URL: https://svnweb.freebsd.org/changeset/base/367502

Log:
  cxgbe(4): Allow the PF driver to set a VF's MAC address.
  
  The MAC address can be set with the optional mac-addr property in the VF
  section of the iovctl.conf(5) used to instantiate the VFs.
  
  MFC after:2 weeks
  Sponsored by: Chelsio Communications

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

Modified: head/sys/dev/cxgbe/common/common.h
==
--- head/sys/dev/cxgbe/common/common.h  Mon Nov  9 00:05:45 2020
(r367501)
+++ head/sys/dev/cxgbe/common/common.h  Mon Nov  9 00:08:35 2020
(r367502)
@@ -691,6 +691,8 @@ void t4_idma_monitor_init(struct adapter *adapter,
 void t4_idma_monitor(struct adapter *adapter,
 struct sge_idma_monitor_state *idma,
 int hz, int ticks);
+int t4_set_vf_mac(struct adapter *adapter, unsigned int pf, unsigned int vf,
+ unsigned int naddr, u8 *addr);
 
 unsigned int t4_get_regs_len(struct adapter *adapter);
 void t4_get_regs(struct adapter *adap, u8 *buf, size_t buf_size);

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Mon Nov  9 00:05:45 2020
(r367501)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Mon Nov  9 00:08:35 2020
(r367502)
@@ -10202,6 +10202,48 @@ void t4_idma_monitor(struct adapter *adapter,
 }
 
 /**
+ * t4_set_vf_mac - Set MAC address for the specified VF
+ * @adapter: The adapter
+ * @pf: the PF used to instantiate the VFs
+ * @vf: one of the VFs instantiated by the specified PF
+ * @naddr: the number of MAC addresses
+ * @addr: the MAC address(es) to be set to the specified VF
+ */
+int t4_set_vf_mac(struct adapter *adapter, unsigned int pf, unsigned int vf,
+ unsigned int naddr, u8 *addr)
+{
+   struct fw_acl_mac_cmd cmd;
+
+   memset(, 0, sizeof(cmd));
+   cmd.op_to_vfn = cpu_to_be32(V_FW_CMD_OP(FW_ACL_MAC_CMD) |
+   F_FW_CMD_REQUEST |
+   F_FW_CMD_WRITE |
+   V_FW_ACL_MAC_CMD_PFN(pf) |
+   V_FW_ACL_MAC_CMD_VFN(vf));
+
+   /* Note: Do not enable the ACL */
+   cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
+   cmd.nmac = naddr;
+
+   switch (pf) {
+   case 3:
+   memcpy(cmd.macaddr3, addr, sizeof(cmd.macaddr3));
+   break;
+   case 2:
+   memcpy(cmd.macaddr2, addr, sizeof(cmd.macaddr2));
+   break;
+   case 1:
+   memcpy(cmd.macaddr1, addr, sizeof(cmd.macaddr1));
+   break;
+   case 0:
+   memcpy(cmd.macaddr0, addr, sizeof(cmd.macaddr0));
+   break;
+   }
+
+   return t4_wr_mbox(adapter, adapter->mbox, , sizeof(cmd), );
+}
+
+/**
  * t4_read_pace_tbl - read the pace table
  * @adap: the adapter
  * @pace_vals: holds the returned values

Modified: head/sys/dev/cxgbe/t4_iov.c
==
--- head/sys/dev/cxgbe/t4_iov.c Mon Nov  9 00:05:45 2020(r367501)
+++ head/sys/dev/cxgbe/t4_iov.c Mon Nov  9 00:08:35 2020(r367502)
@@ -42,12 +42,19 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "common/common.h"
+#include "common/t4_regs.h"
 #include "t4_if.h"
 
 struct t4iov_softc {
device_t sc_dev;
device_t sc_main;
bool sc_attached;
+
+   int pf;
+   int regs_rid;
+   struct resource *regs_res;
+   bus_space_handle_t bh;
+   bus_space_tag_t bt;
 };
 
 struct {
@@ -113,6 +120,13 @@ struct {
{0x6087, "Chelsio T6225-CR 87"},
 };
 
+static inline uint32_t
+t4iov_read_reg(struct t4iov_softc *sc, uint32_t reg)
+{
+
+   return bus_space_read_4(sc->bt, sc->bh, reg);
+}
+
 static int t4iov_attach_child(device_t dev);
 
 static int
@@ -179,10 +193,28 @@ static int
 t4iov_attach(device_t dev)
 {
struct t4iov_softc *sc;
+   uint32_t pl_rev, whoami;
 
sc = device_get_softc(dev);
sc->sc_dev = dev;
 
+   sc->regs_rid = PCIR_BAR(0);
+   sc->regs_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+   >regs_rid, RF_ACTIVE);
+   if (sc->regs_res == NULL) {
+   device_printf(dev, "cannot map registers.\n");
+   return (ENXIO);
+   }
+   sc->bt = rman_get_bustag(sc->regs_res);
+   sc->bh = rman_get_bushandle(sc->regs_res);
+
+   pl_rev = t4iov_read_reg(sc, A_PL_REV);
+   whoami = t4iov_read_reg(sc, A_PL_WHOAMI);
+   if (G_CHIPID(pl_rev) <= CHELSIO_T5)
+   sc->pf = G_SOURCEPF(whoami);
+   else
+   sc->pf = G_T6_SOURCEPF(whoami);
+
   

svn commit: r367497 - in head/sys/dev/cxgbe: . common

2020-11-08 Thread Navdeep Parhar
Author: np
Date: Mon Nov  9 00:01:13 2020
New Revision: 367497
URL: https://svnweb.freebsd.org/changeset/base/367497

Log:
  cxgbev(4): Use the MAC address set by the the PF if there is one.
  
  Query the firmware for the MAC address set by the PF for the VF and use
  it instead of the firmware generated MAC if it's available.
  
  MFC after:2 weeks
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/common/common.h
  head/sys/dev/cxgbe/common/t4vf_hw.c
  head/sys/dev/cxgbe/t4_vf.c

Modified: head/sys/dev/cxgbe/common/common.h
==
--- head/sys/dev/cxgbe/common/common.h  Sun Nov  8 23:34:06 2020
(r367496)
+++ head/sys/dev/cxgbe/common/common.h  Mon Nov  9 00:01:13 2020
(r367497)
@@ -912,6 +912,8 @@ int t4vf_get_sge_params(struct adapter *adapter);
 int t4vf_get_rss_glb_config(struct adapter *adapter);
 int t4vf_get_vfres(struct adapter *adapter);
 int t4vf_prep_adapter(struct adapter *adapter);
+int t4vf_get_vf_mac(struct adapter *adapter, unsigned int port,
+   unsigned int *naddr, u8 *addr);
 int t4_bar2_sge_qregs(struct adapter *adapter, unsigned int qid,
enum t4_bar2_qtype qtype, int user, u64 *pbar2_qoffset,
unsigned int *pbar2_qid);

Modified: head/sys/dev/cxgbe/common/t4vf_hw.c
==
--- head/sys/dev/cxgbe/common/t4vf_hw.c Sun Nov  8 23:34:06 2020
(r367496)
+++ head/sys/dev/cxgbe/common/t4vf_hw.c Mon Nov  9 00:01:13 2020
(r367497)
@@ -382,3 +382,49 @@ int t4vf_prep_adapter(struct adapter *adapter)
 
return 0;
 }
+
+/*
+ * t4vf_get_vf_mac - Get the MAC address to be set to the VI of this VF.
+ * @adapter: The adapter
+ * @port: The port associated with vf
+ * @naddr: the number of ACL MAC addresses returned in addr
+ * @addr: Placeholder for MAC addresses
+ *
+ * Find the MAC address to be set to the VF's VI. The requested MAC address
+ * is from the host OS via callback in the PF driver.
+ */
+int t4vf_get_vf_mac(struct adapter *adapter, unsigned int port,
+   unsigned int *naddr, u8 *addr)
+{
+   struct fw_acl_mac_cmd cmd;
+   int ret;
+
+   memset(, 0, sizeof(cmd));
+   cmd.op_to_vfn = cpu_to_be32(V_FW_CMD_OP(FW_ACL_MAC_CMD) |
+ F_FW_CMD_REQUEST |
+ F_FW_CMD_READ);
+   cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
+   ret = t4vf_wr_mbox(adapter, , sizeof(cmd), );
+   if (ret)
+   return ret;
+
+   if (cmd.nmac < *naddr)
+   *naddr = cmd.nmac;
+
+   switch (port) {
+   case 3:
+   memcpy(addr, cmd.macaddr3, sizeof(cmd.macaddr3));
+   break;
+   case 2:
+   memcpy(addr, cmd.macaddr2, sizeof(cmd.macaddr2));
+   break;
+   case 1:
+   memcpy(addr, cmd.macaddr1, sizeof(cmd.macaddr1));
+   break;
+   case 0:
+   memcpy(addr, cmd.macaddr0, sizeof(cmd.macaddr0));
+   break;
+   }
+
+   return ret;
+}

Modified: head/sys/dev/cxgbe/t4_vf.c
==
--- head/sys/dev/cxgbe/t4_vf.c  Sun Nov  8 23:34:06 2020(r367496)
+++ head/sys/dev/cxgbe/t4_vf.c  Mon Nov  9 00:01:13 2020(r367497)
@@ -481,7 +481,7 @@ static int
 t4vf_attach(device_t dev)
 {
struct adapter *sc;
-   int rc = 0, i, j, rqidx, tqidx;
+   int rc = 0, i, j, rqidx, tqidx, n, p, pmask;
struct make_dev_args mda;
struct intrs_and_queues iaq;
struct sge *s;
@@ -618,8 +618,10 @@ t4vf_attach(device_t dev)
 * First pass over all the ports - allocate VIs and initialize some
 * basic parameters like mac address, port type, etc.
 */
+   pmask = sc->params.vfres.pmask;
for_each_port(sc, i) {
struct port_info *pi;
+   uint8_t mac[ETHER_ADDR_LEN];
 
pi = malloc(sizeof(*pi), M_CXGBE, M_ZERO | M_WAITOK);
sc->port[i] = pi;
@@ -644,6 +646,15 @@ t4vf_attach(device_t dev)
sc->port[i] = NULL;
goto done;
}
+
+   /* Prefer the MAC address set by the PF, if there is one. */
+   n = 1;
+   p = ffs(pmask) - 1;
+   MPASS(p >= 0);
+   rc = t4vf_get_vf_mac(sc, p, , mac);
+   if (rc == 0 && n == 1)
+   t4_os_set_hw_addr(pi, mac);
+   pmask &= ~(1 << p);
 
/* No t4_link_start. */
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367495 - head/sys/dev/cxgbe/firmware

2020-11-08 Thread Navdeep Parhar
Author: np
Date: Sun Nov  8 22:30:13 2020
New Revision: 367495
URL: https://svnweb.freebsd.org/changeset/base/367495

Log:
  cxgbe(4): Add the firmware binaries missing in r367428.
  
  Obtained from:Chelsio Communications
  MFC after:5 days
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin   (contents, props changed)
  head/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin   (contents, props changed)
  head/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin   (contents, props changed)

Modified: head/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin
==
Binary file (source and/or target). No diff available.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367428 - in head/sys: conf dev/cxgbe/firmware modules/cxgbe/t4_firmware modules/cxgbe/t5_firmware modules/cxgbe/t6_firmware

2020-11-06 Thread Navdeep Parhar
Author: np
Date: Fri Nov  6 19:04:20 2020
New Revision: 367428
URL: https://svnweb.freebsd.org/changeset/base/367428

Log:
  cxgbe(4):  Update firmwares to 1.25.0.40.
  
  This fixes a potential crash in firmware 1.25.0.0 on the passive open
  side during TOE operation.
  
  Obtained from:Chelsio Communications
  MFC after:1 week
  Sponsored by: Chelsio Communications

Added:
  head/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin   (contents, props changed)
  head/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin   (contents, props changed)
  head/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin   (contents, props changed)
Deleted:
  head/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin
  head/sys/dev/cxgbe/firmware/t5fw-1.25.0.0.bin
  head/sys/dev/cxgbe/firmware/t6fw-1.25.0.0.bin
Modified:
  head/sys/conf/files
  head/sys/dev/cxgbe/firmware/t4fw_interface.h
  head/sys/modules/cxgbe/t4_firmware/Makefile
  head/sys/modules/cxgbe/t5_firmware/Makefile
  head/sys/modules/cxgbe/t6_firmware/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Fri Nov  6 18:50:00 2020(r367427)
+++ head/sys/conf/files Fri Nov  6 19:04:20 2020(r367428)
@@ -1516,7 +1516,7 @@ t4fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t4fw.fwo"
 t4fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t4fw-1.25.0.0.bin"   \
+   dependency  "$S/dev/cxgbe/firmware/t4fw-1.25.0.40.bin"  \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t4fw.fw"
@@ -1550,7 +1550,7 @@ t5fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t5fw.fwo"
 t5fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t5fw-1.25.0.0.bin"   \
+   dependency  "$S/dev/cxgbe/firmware/t5fw-1.25.0.40.bin"  \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t5fw.fw"
@@ -1584,7 +1584,7 @@ t6fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t6fw.fwo"
 t6fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t6fw-1.25.0.0.bin"   \
+   dependency  "$S/dev/cxgbe/firmware/t6fw-1.25.0.40.bin"  \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t6fw.fw"

Added: head/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin
==

Modified: head/sys/dev/cxgbe/firmware/t4fw_interface.h
==
--- head/sys/dev/cxgbe/firmware/t4fw_interface.hFri Nov  6 18:50:00 
2020(r367427)
+++ head/sys/dev/cxgbe/firmware/t4fw_interface.hFri Nov  6 19:04:20 
2020(r367428)
@@ -9985,17 +9985,17 @@ enum {
T4FW_VERSION_MAJOR  = 1,
T4FW_VERSION_MINOR  = 25,
T4FW_VERSION_MICRO  = 0,
-   T4FW_VERSION_BUILD  = 0,
+   T4FW_VERSION_BUILD  = 40,
 
T5FW_VERSION_MAJOR  = 1,
T5FW_VERSION_MINOR  = 25,
T5FW_VERSION_MICRO  = 0,
-   T5FW_VERSION_BUILD  = 0,
+   T5FW_VERSION_BUILD  = 40,
 
T6FW_VERSION_MAJOR  = 1,
T6FW_VERSION_MINOR  = 25,
T6FW_VERSION_MICRO  = 0,
-   T6FW_VERSION_BUILD  = 0,
+   T6FW_VERSION_BUILD  = 40,
 };
 
 enum {

Added: head/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin
==

Added: head/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin
==

Modified: head/sys/modules/cxgbe/t4_firmware/Makefile
==
--- head/sys/modules/cxgbe/t4_firmware/Makefile Fri Nov  6 18:50:00 2020
(r367427)
+++ head/sys/modules/cxgbe/t4_firmware/Makefile Fri Nov  6 19:04:20 2020
(r367428)
@@ -17,7 +17,7 @@ FIRMWS+=  ${F}:${F:C/.txt//}:1.0.0.0
 .endif
 .endfor
 
-T4FW_VER=  1.25.0.0
+T4FW_VER=  1.25.0.40
 FIRMWS+=   t4fw-${T4FW_VER}.bin:t4fw:${T4FW_VER}
 
 .include 

Modified: head/sys/modules/cxgbe/t5_firmware/Makefile

svn commit: r366959 - head/sys/dev/cxgbe

2020-10-22 Thread Navdeep Parhar
Author: np
Date: Fri Oct 23 02:24:43 2020
New Revision: 366959
URL: https://svnweb.freebsd.org/changeset/base/366959

Log:
  cxgbe(4):  Fix min/max typo in r366958.

Modified:
  head/sys/dev/cxgbe/t4_sched.c

Modified: head/sys/dev/cxgbe/t4_sched.c
==
--- head/sys/dev/cxgbe/t4_sched.c   Fri Oct 23 01:36:54 2020
(r366958)
+++ head/sys/dev/cxgbe/t4_sched.c   Fri Oct 23 02:24:43 2020
(r366959)
@@ -924,10 +924,10 @@ cxgbe_ratelimit_query(struct ifnet *ifp, struct if_rat
if (chip_id(sc) < CHELSIO_T6) {
/* Based on testing by rrs@ with a T580 at burstsize = 4. */
MPASS(q->min_segment_burst == 4);
-   q->max_flows = max(4000, q->max_flows);
+   q->max_flows = min(4000, q->max_flows);
} else {
/* XXX: TBD, carried forward from T5 for now. */
-   q->max_flows = max(4000, q->max_flows);
+   q->max_flows = min(4000, q->max_flows);
}
 
/*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366958 - head/sys/dev/cxgbe

2020-10-22 Thread Navdeep Parhar
Author: np
Date: Fri Oct 23 01:36:54 2020
New Revision: 366958
URL: https://svnweb.freebsd.org/changeset/base/366958

Log:
  cxgbe(4): refine the values reported in if_ratelimit_query.
  
  - Get the number of classes from chip_params.
  - Get the number of ethofld tids from the firmware.
  - Do not let tcp_ratelimit allocate all traffic classes.
  
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_sched.c

Modified: head/sys/dev/cxgbe/t4_sched.c
==
--- head/sys/dev/cxgbe/t4_sched.c   Fri Oct 23 01:06:42 2020
(r366957)
+++ head/sys/dev/cxgbe/t4_sched.c   Fri Oct 23 01:36:54 2020
(r366958)
@@ -903,34 +903,46 @@ cxgbe_rate_tag_free(struct m_snd_tag *mst)
mtx_unlock(>lock);
 }
 
-#define CXGBE_MAX_FLOWS 4000   /* Testing show so far thats all this adapter 
can do */
-#define CXGBE_UNIQUE_RATE_COUNT 16 /* Number of unique rates that can be setup 
*/
-
 void
-cxgbe_ratelimit_query(struct ifnet *ifp __unused,
- struct if_ratelimit_query_results *q)
+cxgbe_ratelimit_query(struct ifnet *ifp, struct if_ratelimit_query_results *q)
 {
-   /*
-* This is a skeleton and needs future work
-* by the driver supporters. It should be
-* enhanced to look at the specific type of
-* interface and select approprate values
-* for these settings. This example goes
-* with an earlier card (t5), it has a maximum
-* number of 16 rates that the first guys in
-* select (thus the flags value RT_IS_SELECTABLE).
-* If it was a fixed table then we would setup a
-* const array (example mlx5). Note the card tested
-* can only support reasonably 4000 flows before
-* the adapter has issues with sending so here 
-* we limit the number of flows using hardware
-* pacing to that number, other cards may
-* be able to raise or eliminate this limit.
-*/
+   struct vi_info *vi = ifp->if_softc;
+   struct adapter *sc = vi->adapter;
+
q->rate_table = NULL;
q->flags = RT_IS_SELECTABLE;
-   q->max_flows = CXGBE_MAX_FLOWS;
-   q->number_of_rates = CXGBE_UNIQUE_RATE_COUNT;
-   q->min_segment_burst = 4;   /* Driver emits 4 in a burst */
+   /*
+* Absolute max limits from the firmware configuration.  Practical
+* limits depend on the burstsize, pktsize (ifp->if_mtu ultimately) and
+* the card's cclk.
+*/
+   q->max_flows = sc->tids.netids;
+   q->number_of_rates = sc->chip_params->nsched_cls;
+   q->min_segment_burst = 4; /* matches PKTSCHED_BURST in the firmware. */
+
+#if 1
+   if (chip_id(sc) < CHELSIO_T6) {
+   /* Based on testing by rrs@ with a T580 at burstsize = 4. */
+   MPASS(q->min_segment_burst == 4);
+   q->max_flows = max(4000, q->max_flows);
+   } else {
+   /* XXX: TBD, carried forward from T5 for now. */
+   q->max_flows = max(4000, q->max_flows);
+   }
+
+   /*
+* XXX: tcp_ratelimit.c grabs all available rates on link-up before it
+* even knows whether hw pacing will be used or not.  This prevents
+* other consumers like SO_MAX_PACING_RATE or those using cxgbetool or
+* the private ioctls from using any of traffic classes.
+*
+* Underreport the number of rates to tcp_ratelimit so that it doesn't
+* hog all of them.  This can be removed if/when tcp_ratelimit switches
+* to making its allocations on first-use rather than link-up.  There is
+* nothing wrong with one particular consumer reserving all the classes
+* but it should do so only if it'll actually use hw rate limiting.
+*/
+   q->number_of_rates /= 4;
+#endif
 }
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366941 - head/sys/net

2020-10-22 Thread Navdeep Parhar
Author: np
Date: Thu Oct 22 17:05:55 2020
New Revision: 366941
URL: https://svnweb.freebsd.org/changeset/base/366941

Log:
  if_vxlan(4): csum_flags_to_inner_flags takes the tunnel protocol as a 
parameter.
  
  No functional change.

Modified:
  head/sys/net/if_vxlan.c

Modified: head/sys/net/if_vxlan.c
==
--- head/sys/net/if_vxlan.c Thu Oct 22 16:41:13 2020(r366940)
+++ head/sys/net/if_vxlan.c Thu Oct 22 17:05:55 2020(r366941)
@@ -2423,9 +2423,9 @@ vxlan_encap_header(struct vxlan_softc *sc, struct mbuf
  * Return the CSUM_INNER_* equivalent of CSUM_* caps.
  */
 static uint32_t
-csum_flags_to_inner_flags(uint32_t csum_flags_in, uint32_t encap)
+csum_flags_to_inner_flags(uint32_t csum_flags_in, const uint32_t encap)
 {
-   uint32_t csum_flags = CSUM_ENCAP_VXLAN;
+   uint32_t csum_flags = encap;
const uint32_t v4 = CSUM_IP | CSUM_IP_UDP | CSUM_IP_TCP;
 
/*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366929 - head/sys/dev/cxgbe

2020-10-22 Thread Navdeep Parhar
Author: np
Date: Thu Oct 22 08:40:25 2020
New Revision: 366929
URL: https://svnweb.freebsd.org/changeset/base/366929

Log:
  cxgbe(4): fix the size of the iq/eq maps.
  
  The firmware can allocate ingress and egress context ids anywhere from
  its configured range.  Size the iq/eq maps to match the entire range
  instead of assuming that the firmware always allocates the first
  available context id.
  
  Reported by:  Baptiste Wicht @ Verisign
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_netmap.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hThu Oct 22 06:51:47 2020
(r366928)
+++ head/sys/dev/cxgbe/adapter.hThu Oct 22 08:40:25 2020
(r366929)
@@ -799,6 +799,8 @@ struct sge {
uint16_t iq_base;   /* first abs_id */
int eq_start;   /* first cntxt_id */
int eq_base;/* first abs_id */
+   int iqmap_sz;
+   int eqmap_sz;
struct sge_iq **iqmap;  /* iq->cntxt_id to iq mapping */
struct sge_eq **eqmap;  /* eq->cntxt_id to eq mapping */
 

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cThu Oct 22 06:51:47 2020
(r366928)
+++ head/sys/dev/cxgbe/t4_main.cThu Oct 22 08:40:25 2020
(r366929)
@@ -1358,6 +1358,8 @@ t4_attach(device_t dev)
s->nm_txq = malloc(s->nnmtxq * sizeof(struct sge_nm_txq),
M_CXGBE, M_ZERO | M_WAITOK);
 #endif
+   MPASS(s->niq <= s->iqmap_sz);
+   MPASS(s->neq <= s->eqmap_sz);
 
s->ctrlq = malloc(nports * sizeof(struct sge_wrq), M_CXGBE,
M_ZERO | M_WAITOK);
@@ -1365,9 +1367,9 @@ t4_attach(device_t dev)
M_ZERO | M_WAITOK);
s->txq = malloc(s->ntxq * sizeof(struct sge_txq), M_CXGBE,
M_ZERO | M_WAITOK);
-   s->iqmap = malloc(s->niq * sizeof(struct sge_iq *), M_CXGBE,
+   s->iqmap = malloc(s->iqmap_sz * sizeof(struct sge_iq *), M_CXGBE,
M_ZERO | M_WAITOK);
-   s->eqmap = malloc(s->neq * sizeof(struct sge_eq *), M_CXGBE,
+   s->eqmap = malloc(s->eqmap_sz * sizeof(struct sge_eq *), M_CXGBE,
M_ZERO | M_WAITOK);
 
sc->irq = malloc(sc->intr_count * sizeof(struct irq), M_CXGBE,
@@ -4456,6 +4458,19 @@ get_params__post_init(struct adapter *sc)
("%s: L2 table size (%u) larger than expected (%u)",
__func__, sc->vres.l2t.size, L2T_SIZE));
sc->params.core_vdd = val[6];
+
+   param[0] = FW_PARAM_PFVF(IQFLINT_END);
+   param[1] = FW_PARAM_PFVF(EQ_END);
+   rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val);
+   if (rc != 0) {
+   device_printf(sc->dev,
+   "failed to query parameters (post_init2): %d.\n", rc);
+   return (rc);
+   }
+   MPASS(val[0] >= sc->sge.iq_start);
+   sc->sge.iqmap_sz = val[0] - sc->sge.iq_start + 1;
+   MPASS(val[1] >= sc->sge.eq_start);
+   sc->sge.eqmap_sz = val[1] - sc->sge.eq_start + 1;
 
if (chip_id(sc) >= CHELSIO_T6) {
 

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Thu Oct 22 06:51:47 2020
(r366928)
+++ head/sys/dev/cxgbe/t4_netmap.c  Thu Oct 22 08:40:25 2020
(r366929)
@@ -188,9 +188,9 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq
nm_rxq->iq_cntxt_id = be16toh(c.iqid);
nm_rxq->iq_abs_id = be16toh(c.physiqid);
cntxt_id = nm_rxq->iq_cntxt_id - sc->sge.iq_start;
-   if (cntxt_id >= sc->sge.niq) {
+   if (cntxt_id >= sc->sge.iqmap_sz) {
panic ("%s: nm_rxq->iq_cntxt_id (%d) more than the max (%d)",
-   __func__, cntxt_id, sc->sge.niq - 1);
+   __func__, cntxt_id, sc->sge.iqmap_sz - 1);
}
sc->sge.iqmap[cntxt_id] = (void *)nm_rxq;
 
@@ -201,9 +201,9 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq
nm_rxq->fl_db_threshold = chip_id(sc) <= CHELSIO_T5 ? 8 : 4;
MPASS(nm_rxq->fl_sidx == na->num_rx_desc);
cntxt_id = nm_rxq->fl_cntxt_id - sc->sge.eq_start;
-   if (cntxt_id >= sc->sge.neq) {
+   if (cntxt_id >= sc->sge.eqmap_sz) {
panic("%s: nm_rxq->fl_cntxt_id (%d) more than the max (%d)",
-   __func__, cntxt_id, sc->sge.neq - 1);
+   __func__, cntxt_id, sc->sge.eqmap_sz - 1);
}
sc->sge.eqmap[cntxt_id] = (void *)nm_rxq;
 
@@ -300,9 +300,9 @@ alloc_nm_txq_hwq(struct vi_info *vi, struct sge_nm_txq
 
nm_txq->cntxt_id = G_FW_EQ_ETH_CMD_EQID(be32toh(c.eqid_pkd));
cntxt_id = nm_txq->cntxt_id - sc->sge.eq_start;
-   if 

svn commit: r366916 - head/sys/dev/cxgbe

2020-10-21 Thread Navdeep Parhar
Author: np
Date: Wed Oct 21 20:42:29 2020
New Revision: 366916
URL: https://svnweb.freebsd.org/changeset/base/366916

Log:
  cxgbe(4): display correct tid range for T6 based -SO cards.
  
  Reported by:  Chelsio QA
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cWed Oct 21 18:45:48 2020
(r366915)
+++ head/sys/dev/cxgbe/t4_main.cWed Oct 21 20:42:29 2020
(r366916)
@@ -9325,8 +9325,10 @@ sysctl_tids(SYSCTL_HANDLER_ARGS)
if (b)
sbuf_printf(sb, "%u-%u, ", t->tid_base, b - 1);
sbuf_printf(sb, "%u-%u", hb, t->ntids - 1);
-   } else
-   sbuf_printf(sb, "%u-%u", t->tid_base, t->ntids - 1);
+   } else {
+   sbuf_printf(sb, "%u-%u", t->tid_base, t->tid_base +
+   t->ntids - 1);
+   }
sbuf_printf(sb, ", in use: %u\n",
atomic_load_acq_int(>tids_in_use));
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366862 - in head: share/man/man4 sys/dev/cxgbe

2020-10-19 Thread Navdeep Parhar
Author: np
Date: Mon Oct 19 21:11:49 2020
New Revision: 366862
URL: https://svnweb.freebsd.org/changeset/base/366862

Log:
  cxgbe(4): Updates to the drop features from r366532.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/share/man/man4/cxgbe.4
  head/sys/dev/cxgbe/t4_main.c

Modified: head/share/man/man4/cxgbe.4
==
--- head/share/man/man4/cxgbe.4 Mon Oct 19 20:43:29 2020(r366861)
+++ head/share/man/man4/cxgbe.4 Mon Oct 19 21:11:49 2020(r366862)
@@ -31,7 +31,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 8, 2020
+.Dd October 19, 2020
 .Dt CXGBE 4
 .Os
 .Sh NAME
@@ -369,6 +369,7 @@ The attack filter will drop an incoming frame if any o
 true: src ip/ip6 == dst ip/ip6; tcp and src/dst ip is not unicast; src/dst ip 
is
 loopback (127.x.y.z); src ip6 is not unicast; src/dst ip6 is loopback (::1/128)
 or unspecified (::/128); tcp and src/dst ip6 is mcast (ff00::/8).
+This facility is available on T4 and T5 based cards only.
 .It Va hw.cxgbe.drop_ip_fragments
 Set to 1 to drop all incoming IP fragments.
 Default is 0.
@@ -378,9 +379,11 @@ Set to 1 to drop incoming frames with Layer 2 length o
 Default is 1.
 .It Va hw.cxgbe.drop_pkts_with_l3_errors
 Set to 1 to drop incoming frames with IP version, length, or checksum errors.
+The IP checksum is validated for TCP or UDP packets only.
 Default is 0.
 .It Va hw.cxgbe.drop_pkts_with_l4_errors
-Set to 1 to drop incoming frames with Layer 4 length, checksum, or other 
errors.
+Set to 1 to drop incoming frames with Layer 4 (TCP or UDP) length,
+checksum, or other errors.
 Default is 0.
 .El
 .Sh SUPPORT

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cMon Oct 19 20:43:29 2020
(r366861)
+++ head/sys/dev/cxgbe/t4_main.cMon Oct 19 21:11:49 2020
(r366862)
@@ -4823,7 +4823,7 @@ set_params__post_init(struct adapter *sc)
F_DROPERRORIPHDRLEN | F_DROPERRORTCPHDRLEN | F_DROPERRORPKTLEN |
F_DROPERRORTCPOPT | F_DROPERRORCSUMIP | F_DROPERRORCSUM;
val = 0;
-   if (t4_attack_filter != 0) {
+   if (chip_id(sc) < CHELSIO_T6 && t4_attack_filter != 0) {
t4_set_reg_field(sc, A_TP_GLOBAL_CONFIG, F_ATTACKFILTERENABLE,
F_ATTACKFILTERENABLE);
val |= F_DROPERRORATTACK;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366853 - head/sys/dev/cxgbe/common

2020-10-19 Thread Navdeep Parhar
Author: np
Date: Mon Oct 19 20:08:47 2020
New Revision: 366853
URL: https://svnweb.freebsd.org/changeset/base/366853

Log:
  cxgbe(4): Fix page fault in t4_get_lb_stats with 2 port T5 cards.
  
  PR:   250449
  Reported by:  freqlabs@
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/common/t4_hw.c

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Mon Oct 19 20:04:03 2020
(r366852)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Mon Oct 19 20:08:47 2020
(r366853)
@@ -6957,7 +6957,6 @@ void t4_get_port_stats(struct adapter *adap, int idx, 
  */
 void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p)
 {
-   u32 bgmap = adap2pinfo(adap, idx)->mps_bg_map;
 
 #define GET_STAT(name) \
t4_read_reg64(adap, \
@@ -6982,14 +6981,18 @@ void t4_get_lb_stats(struct adapter *adap, int idx, st
p->frames_1519_max  = GET_STAT(1519B_MAX);
p->drop = GET_STAT(DROP_FRAMES);
 
-   p->ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_DROP_FRAME) : 0;
-   p->ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_DROP_FRAME) : 0;
-   p->ovflow2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_DROP_FRAME) : 0;
-   p->ovflow3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_DROP_FRAME) : 0;
-   p->trunc0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_TRUNC_FRAME) : 0;
-   p->trunc1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_TRUNC_FRAME) : 0;
-   p->trunc2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_TRUNC_FRAME) : 0;
-   p->trunc3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_TRUNC_FRAME) : 0;
+   if (idx < adap->params.nports) {
+   u32 bg = adap2pinfo(adap, idx)->mps_bg_map;
+
+   p->ovflow0 = (bg & 1) ? GET_STAT_COM(RX_BG_0_LB_DROP_FRAME) : 0;
+   p->ovflow1 = (bg & 2) ? GET_STAT_COM(RX_BG_1_LB_DROP_FRAME) : 0;
+   p->ovflow2 = (bg & 4) ? GET_STAT_COM(RX_BG_2_LB_DROP_FRAME) : 0;
+   p->ovflow3 = (bg & 8) ? GET_STAT_COM(RX_BG_3_LB_DROP_FRAME) : 0;
+   p->trunc0 = (bg & 1) ? GET_STAT_COM(RX_BG_0_LB_TRUNC_FRAME) : 0;
+   p->trunc1 = (bg & 2) ? GET_STAT_COM(RX_BG_1_LB_TRUNC_FRAME) : 0;
+   p->trunc2 = (bg & 4) ? GET_STAT_COM(RX_BG_2_LB_TRUNC_FRAME) : 0;
+   p->trunc3 = (bg & 8) ? GET_STAT_COM(RX_BG_3_LB_TRUNC_FRAME) : 0;
+   }
 
 #undef GET_STAT
 #undef GET_STAT_COM
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366696 - head/sys/dev/cxgbe/common

2020-10-14 Thread Navdeep Parhar
Author: np
Date: Wed Oct 14 10:12:39 2020
New Revision: 366696
URL: https://svnweb.freebsd.org/changeset/base/366696

Log:
  cxgbe(4): Do not request FEC when requesting speeds that don't have FEC.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/common/t4_hw.c

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Wed Oct 14 09:22:54 2020
(r366695)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Wed Oct 14 10:12:39 2020
(r366696)
@@ -3915,7 +3915,7 @@ int t4_link_l1cfg(struct adapter *adap, unsigned int m
speed = fwcap_top_speed(lc->pcaps);
 
fec = 0;
-   if (fec_supported(lc->pcaps)) {
+   if (fec_supported(speed)) {
if (lc->requested_fec == FEC_AUTO) {
if (lc->pcaps & FW_PORT_CAP32_FORCE_FEC) {
if (speed & FW_PORT_CAP32_SPEED_100G) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366694 - head/sys/dev/cxgbe/cudbg

2020-10-14 Thread Navdeep Parhar
Author: np
Date: Wed Oct 14 08:04:39 2020
New Revision: 366694
URL: https://svnweb.freebsd.org/changeset/base/366694

Log:
  cxgbe(4): unimplemented cudbg routines should return the correct
  internal error code and not an errno.
  
  Submitted by: Krishnamraju Eraparaju @ Chelsio
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/cudbg/cudbg_lib.c

Modified: head/sys/dev/cxgbe/cudbg/cudbg_lib.c
==
--- head/sys/dev/cxgbe/cudbg/cudbg_lib.cWed Oct 14 06:25:55 2020
(r366693)
+++ head/sys/dev/cxgbe/cudbg/cudbg_lib.cWed Oct 14 08:04:39 2020
(r366694)
@@ -2027,7 +2027,7 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
 /* CIM OBQ */
 
@@ -2664,7 +2664,7 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
 
 static void collect_mem_info(struct cudbg_init *pdbg_init,
@@ -3130,7 +3130,7 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
 
 static int collect_pbt_tables(struct cudbg_init *pdbg_init,
@@ -4450,5 +4450,5 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366589 - in head/sys/dev/cxgbe: . common

2020-10-09 Thread Navdeep Parhar
Author: np
Date: Fri Oct  9 22:23:39 2020
New Revision: 366589
URL: https://svnweb.freebsd.org/changeset/base/366589

Log:
  cxgbe(4): More fixes for the T6 FCS error counter.
  
  r365732 was the first attempt to get an accurate count but it was
  writing to some read-only registers to clear them and that obviously
  didn't work.  Instead, note the counter's value when it is supposed to
  be cleared and subtract it from future readings.
  
  dev..stats.rx_fcs_error should not be serviced from the MPS
  register for T6.
  
  The stats.* sysctls should all use T5_PORT_REG for T5 and above.  This
  must have been missed in the initial T5 support years ago.  Fix it while
  here.
  
  MFC after:3 days
  Sponsored by: Chelsio Communications

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

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hFri Oct  9 21:01:53 2020
(r366588)
+++ head/sys/dev/cxgbe/adapter.hFri Oct  9 22:23:39 2020
(r366589)
@@ -314,6 +314,8 @@ struct port_info {
struct port_stats stats;
u_int tnl_cong_drops;
u_int tx_parse_error;
+   int fcs_reg;
+   uint64_t fcs_base;
u_long  tx_toe_tls_records;
u_long  tx_toe_tls_octets;
u_long  rx_toe_tls_records;

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Fri Oct  9 21:01:53 2020
(r366588)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Fri Oct  9 22:23:39 2020
(r366589)
@@ -6852,8 +6852,8 @@ void t4_get_port_stats_offset(struct adapter *adap, in
  */
 void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
 {
-   u32 bgmap = adap2pinfo(adap, idx)->mps_bg_map;
-   struct link_config *lc = >port[idx]->link_cfg;
+   struct port_info *pi = adap->port[idx];
+   u32 bgmap = pi->mps_bg_map;
u32 stat_ctl = t4_read_reg(adap, A_MPS_STAT_CTL);
 
 #define GET_STAT(name) \
@@ -6922,25 +6922,8 @@ void t4_get_port_stats(struct adapter *adap, int idx, 
p->rx_ppp6  = GET_STAT(RX_PORT_PPP6);
p->rx_ppp7  = GET_STAT(RX_PORT_PPP7);
 
-   /*
-* The T6's MPS's RX_PORT_CRC_ERROR register doesn't actually count CRC
-* errors so get that information from the MAC instead.  Which MAC is in
-* use depends on speed and FEC.  The MAC counters clear on reset or
-* link state change so we are only reporting errors for this
-* incarnation of the link here.
-*/
-   if (chip_id(adap) != CHELSIO_T6)
-   p->rx_fcs_err = GET_STAT(RX_PORT_CRC_ERROR);
-   else if (lc->link_ok) {
-   if (lc->speed > 25000 ||
-   (lc->speed == 25000 && lc->fec == FEC_RS)) {
-   p->rx_fcs_err = t4_read_reg64(adap, T5_PORT_REG(idx,
-   A_MAC_PORT_AFRAMECHECKSEQUENCEERRORS));
-   } else {
-   p->rx_fcs_err = t4_read_reg64(adap, T5_PORT_REG(idx,
-   A_MAC_PORT_MTIP_1G10G_RX_CRCERRORS));
-   }
-   }
+   if (pi->fcs_reg != -1)
+   p->rx_fcs_err = t4_read_reg64(adap, pi->fcs_reg) - pi->fcs_base;
 
if (chip_id(adap) >= CHELSIO_T5) {
if (stat_ctl & F_COUNTPAUSESTATRX) {
@@ -10769,12 +10752,6 @@ void t4_clr_port_stats(struct adapter *adap, int idx)
t4_write_reg(adap,
A_MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_L + i * 8, 0);
}
-   if (chip_id(adap) == CHELSIO_T6) {
-   t4_write_reg64(adap, T5_PORT_REG(idx,
-   A_MAC_PORT_AFRAMECHECKSEQUENCEERRORS), 0);
-   t4_write_reg64(adap, T5_PORT_REG(idx,
-   A_MAC_PORT_MTIP_1G10G_RX_CRCERRORS), 0);
-   }
 }
 
 /**

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cFri Oct  9 21:01:53 2020
(r366588)
+++ head/sys/dev/cxgbe/t4_main.cFri Oct  9 22:23:39 2020
(r366589)
@@ -1253,6 +1253,23 @@ t4_attach(device_t dev)
mtx_init(>pi_lock, pi->lockname, 0, MTX_DEF);
sc->chan_map[pi->tx_chan] = i;
 
+   /*
+* The MPS counter for FCS errors doesn't work correctly on the
+* T6 so we use the MAC counter here.  Which MAC is in use
+* depends on the link settings which will be known when the
+* link comes up.
+*/
+   if (is_t6(sc)) {
+   pi->fcs_reg = -1;
+   } else if (is_t4(sc)) {
+   pi->fcs_reg = PORT_REG(pi->tx_chan,
+   

svn commit: r366532 - in head: share/man/man4 sys/dev/cxgbe

2020-10-08 Thread Navdeep Parhar
Author: np
Date: Thu Oct  8 10:00:13 2020
New Revision: 366532
URL: https://svnweb.freebsd.org/changeset/base/366532

Log:
  cxgbe(4): knobs to drop various kinds of undesirable frames on ingress.
  
  These kind of drops come for free in the sense that they do not use the
  filter TCAM or any other resource that wouldn't normally be used during
  rx.  Frames dropped by the hardware get counted in the MAC's rx stats
  but are not delivered to the driver.
  
  hw.cxgbe.attack_filter
  Set to 1 to enable the "attack filter".  Default is 0.  The attack
  filter will drop an incoming frame if any of these conditions is true:
  src ip/ip6 == dst ip/ip6; tcp and src/dst ip is not unicast; src/dst ip
  is loopback (127.x.y.z); src ip6 is not unicast; src/dst ip6 is loopback
  (::1/128) or unspecified (::/128); tcp and src/dst ip6 is mcast
  (ff00::/8).
  
  hw.cxgbe.drop_ip_fragments
  Set to 1 to drop all incoming IP fragments.  Default is 0.  Note that
  this drops valid frames.
  
  hw.cxgbe.drop_pkts_with_l2_errors
  Set to 1 to drop incoming frames with Layer 2 length or checksum errors.
  Default is 1.
  
  hw.cxgbe.drop_pkts_with_l3_errors
  Set to 1 to drop incoming frames with IP version, length, or checksum
  errors.  Default is 0.
  
  hw.cxgbe.drop_pkts_with_l4_errors
  Set to 1 to drop incoming frames with Layer 4 length, checksum, or other
  errors.  Default is 0.
  
  MFC after:2 weeks
  Sponsored by: Chelsio Communications

Modified:
  head/share/man/man4/cxgbe.4
  head/sys/dev/cxgbe/t4_main.c

Modified: head/share/man/man4/cxgbe.4
==
--- head/share/man/man4/cxgbe.4 Thu Oct  8 04:00:31 2020(r366531)
+++ head/share/man/man4/cxgbe.4 Thu Oct  8 10:00:13 2020(r366532)
@@ -31,7 +31,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 17, 2020
+.Dd October 8, 2020
 .Dt CXGBE 4
 .Os
 .Sh NAME
@@ -362,6 +362,26 @@ The default value is 0 and should be changed only if P
 to communicate with each other.
 Different interfaces can be assigned different values using the
 dev..X.tx_vm_wr sysctl when the interface is administratively down.
+.It Va hw.cxgbe.attack_filter
+Set to 1 to enable the "attack filter".
+Default is 0.
+The attack filter will drop an incoming frame if any of these conditions is
+true: src ip/ip6 == dst ip/ip6; tcp and src/dst ip is not unicast; src/dst ip 
is
+loopback (127.x.y.z); src ip6 is not unicast; src/dst ip6 is loopback (::1/128)
+or unspecified (::/128); tcp and src/dst ip6 is mcast (ff00::/8).
+.It Va hw.cxgbe.drop_ip_fragments
+Set to 1 to drop all incoming IP fragments.
+Default is 0.
+Note that this drops valid frames.
+.It Va hw.cxgbe.drop_pkts_with_l2_errors
+Set to 1 to drop incoming frames with Layer 2 length or checksum errors.
+Default is 1.
+.It Va hw.cxgbe.drop_pkts_with_l3_errors
+Set to 1 to drop incoming frames with IP version, length, or checksum errors.
+Default is 0.
+.It Va hw.cxgbe.drop_pkts_with_l4_errors
+Set to 1 to drop incoming frames with Layer 4 length, checksum, or other 
errors.
+Default is 0.
 .El
 .Sh SUPPORT
 For general information and support,

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cThu Oct  8 04:00:31 2020
(r366531)
+++ head/sys/dev/cxgbe/t4_main.cThu Oct  8 10:00:13 2020
(r366532)
@@ -595,6 +595,46 @@ static int t4_tx_vm_wr = 0;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, tx_vm_wr, CTLFLAG_RWTUN, _tx_vm_wr, 0,
 "Use VM work requests to transmit packets.");
 
+/*
+ * Set to non-zero to enable the attack filter.  A packet that matches any of
+ * these conditions will get dropped on ingress:
+ * 1) IP && source address == destination address.
+ * 2) TCP/IP && source address is not a unicast address.
+ * 3) TCP/IP && destination address is not a unicast address.
+ * 4) IP && source address is loopback (127.x.y.z).
+ * 5) IP && destination address is loopback (127.x.y.z).
+ * 6) IPv6 && source address == destination address.
+ * 7) IPv6 && source address is not a unicast address.
+ * 8) IPv6 && source address is loopback (::1/128).
+ * 9) IPv6 && destination address is loopback (::1/128).
+ * 10) IPv6 && source address is unspecified (::/128).
+ * 11) IPv6 && destination address is unspecified (::/128).
+ * 12) TCP/IPv6 && source address is multicast (ff00::/8).
+ * 13) TCP/IPv6 && destination address is multicast (ff00::/8).
+ */
+static int t4_attack_filter = 0;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, attack_filter, CTLFLAG_RDTUN,
+_attack_filter, 0, "Drop suspicious traffic");
+
+static int t4_drop_ip_fragments = 0;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, drop_ip_fragments, CTLFLAG_RDTUN,
+_drop_ip_fragments, 0, "Drop IP fragments");
+
+static int t4_drop_pkts_with_l2_errors = 1;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, drop_pkts_with_l2_errors, CTLFLAG_RDTUN,
+_drop_pkts_with_l2_errors, 0,
+"Drop all frames with Layer 2 length or 

svn commit: r366467 - head/sys/dev/cxgbe

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 22:18:04 2020
New Revision: 366467
URL: https://svnweb.freebsd.org/changeset/base/366467

Log:
  cxgbe(4) sysctls do not need Giant.
  
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cMon Oct  5 20:57:44 2020
(r366466)
+++ head/sys/dev/cxgbe/t4_main.cMon Oct  5 22:18:04 2020
(r366467)
@@ -6327,7 +6327,7 @@ t4_sysctls(struct adapter *sc)
sc->params.nports, "# of ports");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "doorbells",
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, doorbells,
+   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, doorbells,
(uintptr_t)>doorbells, sysctl_bitfield_8b, "A",
"available doorbells");
 
@@ -6335,12 +6335,12 @@ t4_sysctls(struct adapter *sc)
sc->params.vpd.cclk, "core clock frequency (in KHz)");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "holdoff_timers",
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
+   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
sc->params.sge.timer_val, sizeof(sc->params.sge.timer_val),
sysctl_int_array, "A", "interrupt holdoff timer values (us)");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "holdoff_pkt_counts",
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
+   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
sc->params.sge.counter_val, sizeof(sc->params.sge.counter_val),
sysctl_int_array, "A", "interrupt holdoff packet counter values");
 
@@ -6400,7 +6400,7 @@ t4_sysctls(struct adapter *sc)
 
 #define SYSCTL_CAP(name, n, text) \
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, #name, \
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, caps_decoder[n], \
+   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, caps_decoder[n], \
(uintptr_t)>name, sysctl_bitfield_16b, "A", \
"available " text " capabilities")
 
@@ -6419,27 +6419,27 @@ t4_sysctls(struct adapter *sc)
NULL, sc->tids.nftids, "number of filters");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "temperature",
-   CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0,
+   CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0,
sysctl_temperature, "I", "chip temperature (in Celsius)");
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "reset_sensor",
-   CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
+   CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0,
sysctl_reset_sensor, "I", "reset the chip's temperature sensor.");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "loadavg",
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0,
+   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0,
sysctl_loadavg, "A",
"microprocessor load averages (debug firmwares only)");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "core_vdd",
-   CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0, sysctl_vdd,
+   CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, sysctl_vdd,
"I", "core Vdd (in mV)");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "local_cpus",
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, LOCAL_CPUS,
+   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, LOCAL_CPUS,
sysctl_cpus, "A", "local CPUs");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_cpus",
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, INTR_CPUS,
+   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, INTR_CPUS,
sysctl_cpus, "A", "preferred CPUs for interrupts");
 
SYSCTL_ADD_INT(ctx, children, OID_AUTO, "swintr", CTLFLAG_RW,
@@ -6454,175 +6454,175 @@ t4_sysctls(struct adapter *sc)
children = SYSCTL_CHILDREN(oid);
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cctrl",
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0,
+   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0,
sysctl_cctrl, "A", "congestion control");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cim_ibq_tp0",
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0,
+   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0,
sysctl_cim_ibq_obq, "A", "CIM IBQ 0 (TP0)");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cim_ibq_tp1",
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 1,
+   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 1,
sysctl_cim_ibq_obq, "A", "CIM IBQ 1 (TP1)");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cim_ibq_ulp",
-   CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 2,
+   

svn commit: r366463 - stable/12/sys/dev/cxgbe

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 19:45:11 2020
New Revision: 366463
URL: https://svnweb.freebsd.org/changeset/base/366463

Log:
  MFC r366354:
  
  cxgbe(4): validate largest_rx_cluster and safest_rx_cluster.
  
  These tunables can only be set to a valid cluster size (2K, 4K, 9K, or
  16K) as documented in the man page.  Anything else could lead to a
  panic on interface up.
  
  Reported by:  mav@
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/t4_sge.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/t4_sge.c
==
--- stable/12/sys/dev/cxgbe/t4_sge.cMon Oct  5 19:38:51 2020
(r366462)
+++ stable/12/sys/dev/cxgbe/t4_sge.cMon Oct  5 19:45:11 2020
(r366463)
@@ -538,6 +538,28 @@ t4_sge_modload(void)
tscale = 1;
}
 
+   if (largest_rx_cluster != MCLBYTES &&
+#if MJUMPAGESIZE != MCLBYTES
+   largest_rx_cluster != MJUMPAGESIZE &&
+#endif
+   largest_rx_cluster != MJUM9BYTES &&
+   largest_rx_cluster != MJUM16BYTES) {
+   printf("Invalid hw.cxgbe.largest_rx_cluster value (%d),"
+   " using %d instead.\n", largest_rx_cluster, MJUM16BYTES);
+   largest_rx_cluster = MJUM16BYTES;
+   }
+
+   if (safest_rx_cluster != MCLBYTES &&
+#if MJUMPAGESIZE != MCLBYTES
+   safest_rx_cluster != MJUMPAGESIZE &&
+#endif
+   safest_rx_cluster != MJUM9BYTES &&
+   safest_rx_cluster != MJUM16BYTES) {
+   printf("Invalid hw.cxgbe.safest_rx_cluster value (%d),"
+   " using %d instead.\n", safest_rx_cluster, MJUMPAGESIZE);
+   safest_rx_cluster = MJUMPAGESIZE;
+   }
+
extfree_refs = counter_u64_alloc(M_WAITOK);
extfree_rels = counter_u64_alloc(M_WAITOK);
pullups = counter_u64_alloc(M_WAITOK);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366460 - stable/12/sys/dev/cxgbe

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 19:22:28 2020
New Revision: 366460
URL: https://svnweb.freebsd.org/changeset/base/366460

Log:
  MFC r366247:
  
  cxgbe(4): Avoid unnecessary work in the firmware during netmap tx.
  
  Bind the netmap tx queues to a special '0xff' scheduling class which
  makes the firmware skip some processing related to rate limiting on the
  outgoing traffic.  Future firmwares will do this automatically.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/t4_netmap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/t4_netmap.c
==
--- stable/12/sys/dev/cxgbe/t4_netmap.c Mon Oct  5 18:59:10 2020
(r366459)
+++ stable/12/sys/dev/cxgbe/t4_netmap.c Mon Oct  5 19:22:28 2020
(r366460)
@@ -329,6 +329,22 @@ alloc_nm_txq_hwq(struct vi_info *vi, struct sge_nm_txq
nm_txq->udb = (volatile void *)udb;
}
 
+   if (sc->params.fw_vers < FW_VERSION32(1, 25, 1, 0)) {
+   uint32_t param, val;
+
+   param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
+   V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_EQ_SCHEDCLASS_ETH) 
|
+   V_FW_PARAMS_PARAM_YZ(nm_txq->cntxt_id);
+   val = 0xff;
+   rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, , );
+   if (rc != 0) {
+   device_printf(vi->dev,
+   "failed to bind netmap txq %d to class 0xff: %d\n",
+   nm_txq->cntxt_id, rc);
+   rc = 0;
+   }
+   }
+
return (rc);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366459 - stable/12/sys/dev/cxgbe

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 18:59:10 2020
New Revision: 366459
URL: https://svnweb.freebsd.org/changeset/base/366459

Log:
  MFC r366246:
  
  Remove duplicate line.

Modified:
  stable/12/sys/dev/cxgbe/t4_netmap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/t4_netmap.c
==
--- stable/12/sys/dev/cxgbe/t4_netmap.c Mon Oct  5 18:49:55 2020
(r366458)
+++ stable/12/sys/dev/cxgbe/t4_netmap.c Mon Oct  5 18:59:10 2020
(r366459)
@@ -216,9 +216,6 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq
param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_CONM_CTXT) |
V_FW_PARAMS_PARAM_YZ(nm_rxq->iq_cntxt_id);
-   param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
-   V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_CONM_CTXT) |
-   V_FW_PARAMS_PARAM_YZ(nm_rxq->iq_cntxt_id);
if (cong == 0)
val = 1 << 19;
else {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366458 - stable/12/sys/dev/cxgbe

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 18:49:55 2020
New Revision: 366458
URL: https://svnweb.freebsd.org/changeset/base/366458

Log:
  MFC r366245:
  
  cxgbe(4): adjust the doorbell threshold for netmap freelists to match the
  maximum burst size used when fetching descriptors from the list.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/t4_netmap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Mon Oct  5 18:47:12 2020
(r366457)
+++ stable/12/sys/dev/cxgbe/adapter.h   Mon Oct  5 18:49:55 2020
(r366458)
@@ -716,6 +716,7 @@ struct sge_nm_rxq {
uint32_t fl_sidx2;  /* copy of fl_sidx */
uint32_t fl_db_val;
u_int fl_db_saved;
+   u_int fl_db_threshold;  /* in descriptors */
u_int fl_hwidx:4;
 
/*

Modified: stable/12/sys/dev/cxgbe/t4_netmap.c
==
--- stable/12/sys/dev/cxgbe/t4_netmap.c Mon Oct  5 18:47:12 2020
(r366457)
+++ stable/12/sys/dev/cxgbe/t4_netmap.c Mon Oct  5 18:49:55 2020
(r366458)
@@ -196,6 +196,9 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq
 
nm_rxq->fl_cntxt_id = be16toh(c.fl0id);
nm_rxq->fl_pidx = nm_rxq->fl_cidx = 0;
+   nm_rxq->fl_db_saved = 0;
+   /* matches the X_FETCHBURSTMAX_512B or X_FETCHBURSTMAX_256B above. */
+   nm_rxq->fl_db_threshold = chip_id(sc) <= CHELSIO_T5 ? 8 : 4;
MPASS(nm_rxq->fl_sidx == na->num_rx_desc);
cntxt_id = nm_rxq->fl_cntxt_id - sc->sge.eq_start;
if (cntxt_id >= sc->sge.neq) {
@@ -1063,7 +1066,7 @@ cxgbe_netmap_rxsync(struct netmap_kring *kring, int fl
fl_pidx = 0;
slot = >slot[0];
}
-   if (++dbinc == 8 && n >= 32) {
+   if (++dbinc == nm_rxq->fl_db_threshold) {
wmb();
if (starve_fl)
nm_rxq->fl_db_saved += dbinc;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366457 - stable/12/sys/dev/cxgbe

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 18:47:12 2020
New Revision: 366457
URL: https://svnweb.freebsd.org/changeset/base/366457

Log:
  MFC r366244:
  
  cxgbe(4): display an error message when netmap cannot be enabled because
  the interface is down.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/t4_netmap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/t4_netmap.c
==
--- stable/12/sys/dev/cxgbe/t4_netmap.c Mon Oct  5 18:46:14 2020
(r366456)
+++ stable/12/sys/dev/cxgbe/t4_netmap.c Mon Oct  5 18:47:12 2020
(r366457)
@@ -536,8 +536,11 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi
MPASS(vi->nnmtxq > 0);
 
if ((vi->flags & VI_INIT_DONE) == 0 ||
-   (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+   (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+   if_printf(ifp, "cannot enable netmap operation because "
+   "interface is not UP.\n");
return (EAGAIN);
+   }
 
rxb = >sge.rx_buf_info[0];
for (i = 0; i < SW_ZONE_SIZES; i++, rxb++) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366455 - stable/12/sys/dev/cxgbe

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 18:45:32 2020
New Revision: 366455
URL: https://svnweb.freebsd.org/changeset/base/366455

Log:
  MFC r366242:
  
  cxgbe(4): fixes for netmap operation with only some queues active.
  
  - Only active netmap receive queues should be in the RSS lookup table.
  
  - The RSS table should be restored for NIC operation when the last
active netmap queue is switched off, not the first one.
  
  - Support repeated netmap ON/OFF on a subset of the queues.  This works
whether the the queues being enabled and disabled are the only ones
active or not.  Some kring indexes have to be reset in the driver for
the second case.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/t4_netmap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/t4_netmap.c
==
--- stable/12/sys/dev/cxgbe/t4_netmap.c Mon Oct  5 18:41:35 2020
(r366454)
+++ stable/12/sys/dev/cxgbe/t4_netmap.c Mon Oct  5 18:45:32 2020
(r366455)
@@ -347,6 +347,180 @@ free_nm_txq_hwq(struct vi_info *vi, struct sge_nm_txq 
 }
 
 static int
+cxgbe_netmap_simple_rss(struct adapter *sc, struct vi_info *vi,
+struct ifnet *ifp, struct netmap_adapter *na)
+{
+   struct netmap_kring *kring;
+   struct sge_nm_rxq *nm_rxq;
+   int rc, i, j, nm_state, defq;
+   uint16_t *rss;
+
+   /*
+* Check if there's at least one active (or about to go active) netmap
+* rx queue.
+*/
+   defq = -1;
+   for_each_nm_rxq(vi, j, nm_rxq) {
+   nm_state = atomic_load_int(_rxq->nm_state);
+   kring = na->rx_rings[nm_rxq->nid];
+   if ((nm_state != NM_OFF && !nm_kring_pending_off(kring)) ||
+   (nm_state == NM_OFF && nm_kring_pending_on(kring))) {
+   MPASS(nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID);
+   if (defq == -1) {
+   defq = nm_rxq->iq_abs_id;
+   break;
+   }
+   }
+   }
+
+   if (defq == -1) {
+   /* No active netmap queues.  Switch back to NIC queues. */
+   rss = vi->rss;
+   defq = vi->rss[0];
+   } else {
+   for (i = 0; i < vi->rss_size;) {
+   for_each_nm_rxq(vi, j, nm_rxq) {
+   nm_state = atomic_load_int(_rxq->nm_state);
+   kring = na->rx_rings[nm_rxq->nid];
+   if ((nm_state != NM_OFF &&
+   !nm_kring_pending_off(kring)) ||
+   (nm_state == NM_OFF &&
+   nm_kring_pending_on(kring))) {
+   MPASS(nm_rxq->iq_cntxt_id !=
+   INVALID_NM_RXQ_CNTXT_ID);
+   vi->nm_rss[i++] = nm_rxq->iq_abs_id;
+   if (i == vi->rss_size)
+   break;
+   }
+   }
+   }
+   rss = vi->nm_rss;
+   }
+
+   rc = -t4_config_rss_range(sc, sc->mbox, vi->viid, 0, vi->rss_size, rss,
+   vi->rss_size);
+   if (rc != 0)
+   if_printf(ifp, "netmap rss_config failed: %d\n", rc);
+
+   rc = -t4_config_vi_rss(sc, sc->mbox, vi->viid, vi->hashen, defq, 0, 0);
+   if (rc != 0) {
+   if_printf(ifp, "netmap defaultq config failed: %d\n", rc);
+   }
+
+   return (rc);
+}
+
+/*
+ * Odd number of rx queues work best for split RSS mode as the first queue can
+ * be dedicated for non-RSS traffic and the rest divided into two equal halves.
+ */
+static int
+cxgbe_netmap_split_rss(struct adapter *sc, struct vi_info *vi,
+struct ifnet *ifp, struct netmap_adapter *na)
+{
+   struct netmap_kring *kring;
+   struct sge_nm_rxq *nm_rxq;
+   int rc, i, j, nm_state, defq;
+   int nactive[2] = {0, 0};
+   int dq[2] = {-1, -1};
+   bool dq_norss;  /* default queue should not be in RSS table. */
+
+   MPASS(nm_split_rss != 0);
+   MPASS(vi->nnmrxq > 1);
+
+   for_each_nm_rxq(vi, i, nm_rxq) {
+   j = i / ((vi->nnmrxq + 1) / 2);
+   nm_state = atomic_load_int(_rxq->nm_state);
+   kring = na->rx_rings[nm_rxq->nid];
+   if ((nm_state != NM_OFF && !nm_kring_pending_off(kring)) ||
+   (nm_state == NM_OFF && nm_kring_pending_on(kring))) {
+   MPASS(nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID);
+   nactive[j]++;
+   if (dq[j] == -1) {
+   dq[j] = nm_rxq->iq_abs_id;
+   break;
+   }
+   }
+ 

svn commit: r366451 - releng/12.2/sys/dev/cxgbe/tom

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 16:39:38 2020
New Revision: 366451
URL: https://svnweb.freebsd.org/changeset/base/366451

Log:
  MFS r366438:
  cxgbe(4): set up the firmware flowc for the tid before send_abort_rpl.
  
  Approved by:  re@ (gjb@)
  Sponsored by: Chelsio Communications

Modified:
  releng/12.2/sys/dev/cxgbe/tom/t4_listen.c
Directory Properties:
  releng/12.2/   (props changed)

Modified: releng/12.2/sys/dev/cxgbe/tom/t4_listen.c
==
--- releng/12.2/sys/dev/cxgbe/tom/t4_listen.c   Mon Oct  5 15:54:19 2020
(r366450)
+++ releng/12.2/sys/dev/cxgbe/tom/t4_listen.c   Mon Oct  5 16:39:38 2020
(r366451)
@@ -341,48 +341,32 @@ release_lctx(struct adapter *sc, struct listen_ctx *lc
 }
 
 static void
-send_reset_synqe(struct toedev *tod, struct synq_entry *synqe)
+send_flowc_wr_synqe(struct adapter *sc, struct synq_entry *synqe)
 {
-   struct adapter *sc = tod->tod_softc;
struct mbuf *m = synqe->syn;
struct ifnet *ifp = m->m_pkthdr.rcvif;
struct vi_info *vi = ifp->if_softc;
struct port_info *pi = vi->pi;
-   struct l2t_entry *e = >l2t->l2tab[synqe->params.l2t_idx];
struct wrqe *wr;
struct fw_flowc_wr *flowc;
-   struct cpl_abort_req *req;
-   int flowclen;
struct sge_wrq *ofld_txq;
struct sge_ofld_rxq *ofld_rxq;
const int nparams = 6;
+   const int flowclen = sizeof(*flowc) + nparams * sizeof(struct 
fw_flowc_mnemval);
const u_int pfvf = sc->pf << S_FW_VIID_PFN;
 
INP_WLOCK_ASSERT(synqe->lctx->inp);
+   MPASS((synqe->flags & TPF_FLOWC_WR_SENT) == 0);
 
-   CTR5(KTR_CXGBE, "%s: synqe %p (0x%x), tid %d%s",
-   __func__, synqe, synqe->flags, synqe->tid,
-   synqe->flags & TPF_ABORT_SHUTDOWN ?
-   " (abort already in progress)" : "");
-   if (synqe->flags & TPF_ABORT_SHUTDOWN)
-   return; /* abort already in progress */
-   synqe->flags |= TPF_ABORT_SHUTDOWN;
-
ofld_txq = >sge.ofld_txq[synqe->params.txq_idx];
ofld_rxq = >sge.ofld_rxq[synqe->params.rxq_idx];
 
-   /* The wrqe will have two WRs - a flowc followed by an abort_req */
-   flowclen = sizeof(*flowc) + nparams * sizeof(struct fw_flowc_mnemval);
-
-   wr = alloc_wrqe(roundup2(flowclen, EQ_ESIZE) + sizeof(*req), ofld_txq);
+   wr = alloc_wrqe(roundup2(flowclen, 16), ofld_txq);
if (wr == NULL) {
/* XXX */
panic("%s: allocation failure.", __func__);
}
flowc = wrtod(wr);
-   req = (void *)((caddr_t)flowc + roundup2(flowclen, EQ_ESIZE));
-
-   /* First the flowc ... */
memset(flowc, 0, wr->wr_len);
flowc->op_to_nparams = htobe32(V_FW_WR_OP(FW_FLOWC_WR) |
V_FW_FLOWC_WR_NPARAMS(nparams));
@@ -396,19 +380,47 @@ send_reset_synqe(struct toedev *tod, struct synq_entry
flowc->mnemval[2].val = htobe32(pi->tx_chan);
flowc->mnemval[3].mnemonic = FW_FLOWC_MNEM_IQID;
flowc->mnemval[3].val = htobe32(ofld_rxq->iq.abs_id);
-   flowc->mnemval[4].mnemonic = FW_FLOWC_MNEM_SNDBUF;
-   flowc->mnemval[4].val = htobe32(512);
-   flowc->mnemval[5].mnemonic = FW_FLOWC_MNEM_MSS;
-   flowc->mnemval[5].val = htobe32(512);
+   flowc->mnemval[4].mnemonic = FW_FLOWC_MNEM_SNDBUF;
+   flowc->mnemval[4].val = htobe32(512);
+   flowc->mnemval[5].mnemonic = FW_FLOWC_MNEM_MSS;
+   flowc->mnemval[5].val = htobe32(512);
+
synqe->flags |= TPF_FLOWC_WR_SENT;
+   t4_wrq_tx(sc, wr);
+}
 
-   /* ... then ABORT request */
+static void
+send_reset_synqe(struct toedev *tod, struct synq_entry *synqe)
+{
+   struct adapter *sc = tod->tod_softc;
+   struct wrqe *wr;
+   struct cpl_abort_req *req;
+
+   INP_WLOCK_ASSERT(synqe->lctx->inp);
+
+   CTR5(KTR_CXGBE, "%s: synqe %p (0x%x), tid %d%s",
+   __func__, synqe, synqe->flags, synqe->tid,
+   synqe->flags & TPF_ABORT_SHUTDOWN ?
+   " (abort already in progress)" : "");
+   if (synqe->flags & TPF_ABORT_SHUTDOWN)
+   return; /* abort already in progress */
+   synqe->flags |= TPF_ABORT_SHUTDOWN;
+
+   if (!(synqe->flags & TPF_FLOWC_WR_SENT))
+   send_flowc_wr_synqe(sc, synqe);
+
+   wr = alloc_wrqe(sizeof(*req), >sge.ofld_txq[synqe->params.txq_idx]);
+   if (wr == NULL) {
+   /* XXX */
+   panic("%s: allocation failure.", __func__);
+   }
+   req = wrtod(wr);
INIT_TP_WR_MIT_CPL(req, CPL_ABORT_REQ, synqe->tid);
req->rsvd0 = 0; /* don't have a snd_nxt */
req->rsvd1 = 1; /* no data sent yet */
req->cmd = CPL_ABORT_SEND_RST;
 
-   t4_l2t_send(sc, wr, e);
+   t4_l2t_send(sc, wr, >l2t->l2tab[synqe->params.l2t_idx]);
 }
 
 static int
@@ -888,6 +900,9 @@ do_abort_req_synqe(struct sge_iq *iq, const struct rss
INP_WLOCK(inp);
 
ofld_txq = 

svn commit: r366443 - in stable/12: share/man/man4 sys/dev/cxgbe

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 09:03:17 2020
New Revision: 366443
URL: https://svnweb.freebsd.org/changeset/base/366443

Log:
  MFC r365993:
  
  cxgbe(4): let the PF driver use VM work requests for transmit.
  
  This allows the PF interfaces to communicate with the VF interfaces over
  the internal switch in the ASIC.  Fix the GL limits for VM work requests
  while here.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/share/man/man4/cxgbe.4
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/t4_main.c
  stable/12/sys/dev/cxgbe/t4_sge.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/cxgbe.4
==
--- stable/12/share/man/man4/cxgbe.4Mon Oct  5 08:51:03 2020
(r366442)
+++ stable/12/share/man/man4/cxgbe.4Mon Oct  5 09:03:17 2020
(r366443)
@@ -351,6 +351,17 @@ This tunable is for specialized applications only and 
 normal operation.
 The capabilities for which hardware resources have been reserved are listed in
 dev..X.*caps sysctls.
+.It Va hw.cxgbe.tx_vm_wr
+Setting this to 1 instructs the driver to use VM work requests to transmit 
data.
+This lets PF interfaces transmit frames to VF interfaces over the internal
+switch in the ASIC.
+Note that the
+.Xr cxgbev 4
+VF driver always uses VM work requests and is not affected by this tunable.
+The default value is 0 and should be changed only if PF and VF interfaces need
+to communicate with each other.
+Different interfaces can be assigned different values using the
+dev..X.tx_vm_wr sysctl when the interface is administratively down.
 .El
 .Sh SUPPORT
 For general information and support,

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Mon Oct  5 08:51:03 2020
(r366442)
+++ stable/12/sys/dev/cxgbe/adapter.h   Mon Oct  5 09:03:17 2020
(r366443)
@@ -120,6 +120,8 @@ enum {
SGE_MAX_WR_NDESC = SGE_MAX_WR_LEN / EQ_ESIZE, /* max WR size in desc */
TX_SGL_SEGS = 39,
TX_SGL_SEGS_TSO = 38,
+   TX_SGL_SEGS_VM = 38,
+   TX_SGL_SEGS_VM_TSO = 37,
TX_SGL_SEGS_EO_TSO = 30,/* XXX: lower for IPv6. */
TX_SGL_SEGS_VXLAN_TSO = 37,
TX_WR_FLITS = SGE_MAX_WR_LEN / 8
@@ -174,6 +176,7 @@ enum {
DOOMED  = (1 << 0),
VI_INIT_DONE= (1 << 1),
VI_SYSCTL_CTX   = (1 << 2),
+   TX_USES_VM_WR   = (1 << 3),
 
/* adapter debug_flags */
DF_DUMP_MBOX= (1 << 0), /* Log all mbox cmd/rpl. */
@@ -1238,7 +1241,7 @@ void t4_intr_evt(void *);
 void t4_wrq_tx_locked(struct adapter *, struct sge_wrq *, struct wrqe *);
 void t4_update_fl_bufsize(struct ifnet *);
 struct mbuf *alloc_wr_mbuf(int, int);
-int parse_pkt(struct adapter *, struct mbuf **);
+int parse_pkt(struct mbuf **, bool);
 void *start_wrq_wr(struct sge_wrq *, int, struct wrq_cookie *);
 void commit_wrq_wr(struct sge_wrq *, void *, struct wrq_cookie *);
 int tnl_cong(struct port_info *, int);

Modified: stable/12/sys/dev/cxgbe/t4_main.c
==
--- stable/12/sys/dev/cxgbe/t4_main.c   Mon Oct  5 08:51:03 2020
(r366442)
+++ stable/12/sys/dev/cxgbe/t4_main.c   Mon Oct  5 09:03:17 2020
(r366443)
@@ -575,6 +575,10 @@ static int t4_panic_on_fatal_err = 0;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, panic_on_fatal_err, CTLFLAG_RDTUN,
 _panic_on_fatal_err, 0, "panic on fatal errors");
 
+static int t4_tx_vm_wr = 0;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, tx_vm_wr, CTLFLAG_RWTUN, _tx_vm_wr, 0,
+"Use VM work requests to transmit packets.");
+
 #ifdef TCP_OFFLOAD
 /*
  * TOE tunables.
@@ -655,6 +659,7 @@ static int sysctl_bitfield_8b(SYSCTL_HANDLER_ARGS);
 static int sysctl_bitfield_16b(SYSCTL_HANDLER_ARGS);
 static int sysctl_btphy(SYSCTL_HANDLER_ARGS);
 static int sysctl_noflowq(SYSCTL_HANDLER_ARGS);
+static int sysctl_tx_vm_wr(SYSCTL_HANDLER_ARGS);
 static int sysctl_holdoff_tmr_idx(SYSCTL_HANDLER_ARGS);
 static int sysctl_holdoff_pktc_idx(SYSCTL_HANDLER_ARGS);
 static int sysctl_qsize_rxq(SYSCTL_HANDLER_ARGS);
@@ -1669,6 +1674,8 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
 
vi->xact_addr_filt = -1;
callout_init(>tick, 1);
+   if (sc->flags & IS_VF || t4_tx_vm_wr != 0)
+   vi->flags |= TX_USES_VM_WR;
 
/* Allocate an ifnet and set it up */
ifp = if_alloc(IFT_ETHER);
@@ -1718,7 +1725,10 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
 #endif
 
ifp->if_hw_tsomax = IP_MAXPACKET;
-   ifp->if_hw_tsomaxsegcount = TX_SGL_SEGS_TSO;
+   if (vi->flags & TX_USES_VM_WR)
+   ifp->if_hw_tsomaxsegcount = TX_SGL_SEGS_VM_TSO;
+   else
+   ifp->if_hw_tsomaxsegcount = TX_SGL_SEGS_TSO;
 #ifdef RATELIMIT
if (is_ethoffload(sc) && vi->nofldtxq != 0)

svn commit: r366442 - in stable/12: share/man/man4 sys/dev/cxgbe sys/dev/cxgbe/common sys/dev/cxgbe/firmware

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 08:51:03 2020
New Revision: 366442
URL: https://svnweb.freebsd.org/changeset/base/366442

Log:
  MFC r365871.  This needs a couple other revisions which aren't in
  stable/12 yet to actually work but is being committed out of order to
  ease other cxgbe MFCs.
  
  r365871:
  cxgbe(4): add support for stateless offloads for VXLAN traffic.
  
  Hardware assistance includes checksumming (tx and rx), TSO, and RSS on
  the inner traffic in a VXLAN tunnel.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/share/man/man4/cxgbe.4
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/common/common.h
  stable/12/sys/dev/cxgbe/common/t4_hw.c
  stable/12/sys/dev/cxgbe/firmware/t6fw_cfg.txt
  stable/12/sys/dev/cxgbe/t4_main.c
  stable/12/sys/dev/cxgbe/t4_sge.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/cxgbe.4
==
--- stable/12/share/man/man4/cxgbe.4Mon Oct  5 07:26:06 2020
(r366441)
+++ stable/12/share/man/man4/cxgbe.4Mon Oct  5 08:51:03 2020
(r366442)
@@ -31,7 +31,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd Dec 10, 2019
+.Dd September 17, 2020
 .Dt CXGBE 4
 .Os
 .Sh NAME
@@ -61,8 +61,8 @@ driver provides support for PCI Express Ethernet adapt
 the Chelsio Terminator 4, Terminator 5, and Terminator 6 ASICs (T4, T5, and 
T6).
 The driver supports Jumbo Frames, Transmit/Receive checksum offload,
 TCP segmentation offload (TSO), Large Receive Offload (LRO), VLAN
-tag insertion/extraction, VLAN checksum offload, VLAN TSO, and
-Receive Side Steering (RSS).
+tag insertion/extraction, VLAN checksum offload, VLAN TSO, VXLAN checksum
+offload, VXLAN TSO, and Receive Side Steering (RSS).
 For further hardware information and questions related to hardware
 requirements, see
 .Pa http://www.chelsio.com/ .

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Mon Oct  5 07:26:06 2020
(r366441)
+++ stable/12/sys/dev/cxgbe/adapter.h   Mon Oct  5 08:51:03 2020
(r366442)
@@ -121,6 +121,7 @@ enum {
TX_SGL_SEGS = 39,
TX_SGL_SEGS_TSO = 38,
TX_SGL_SEGS_EO_TSO = 30,/* XXX: lower for IPv6. */
+   TX_SGL_SEGS_VXLAN_TSO = 37,
TX_WR_FLITS = SGE_MAX_WR_LEN / 8
 };
 
@@ -286,6 +287,7 @@ struct port_info {
int nvi;
int up_vis;
int uld_vis;
+   bool vxlan_tcam_entry;
 
struct tx_sched_params *sched_params;
 
@@ -593,6 +595,8 @@ struct sge_txq {
uint64_t txpkts0_pkts;  /* # of frames in type0 coalesced tx WRs */
uint64_t txpkts1_pkts;  /* # of frames in type1 coalesced tx WRs */
uint64_t raw_wrs;   /* # of raw work requests (alloc_wr_mbuf) */
+   uint64_t vxlan_tso_wrs; /* # of VXLAN TSO work requests */
+   uint64_t vxlan_txcsum;
 
/* stats for not-that-common events */
 } __aligned(CACHE_LINE_SIZE);
@@ -611,6 +615,7 @@ struct sge_rxq {
 
uint64_t rxcsum;/* # of times hardware assisted with checksum */
uint64_t vlan_extraction;/* # of times VLAN tag was extracted */
+   uint64_t vxlan_rxcsum;
 
/* stats for not-that-common events */
 
@@ -833,6 +838,11 @@ struct adapter {
struct sge sge;
int lro_timeout;
int sc_do_rxcopy;
+
+   int vxlan_port;
+   u_int vxlan_refcount;
+   int rawf_base;
+   int nrawf;
 
struct taskqueue *tq[MAX_NCHAN];/* General purpose taskqueues */
struct port_info *port[MAX_NPORTS];

Modified: stable/12/sys/dev/cxgbe/common/common.h
==
--- stable/12/sys/dev/cxgbe/common/common.h Mon Oct  5 07:26:06 2020
(r366441)
+++ stable/12/sys/dev/cxgbe/common/common.h Mon Oct  5 08:51:03 2020
(r366442)
@@ -249,7 +249,7 @@ struct tp_params {
uint32_t max_rx_pdu;
uint32_t max_tx_pdu;
uint64_t hash_filter_mask;
-   __be16 err_vec_mask;
+   bool rx_pkt_encap;
 
int8_t fcoe_shift;
int8_t port_shift;

Modified: stable/12/sys/dev/cxgbe/common/t4_hw.c
==
--- stable/12/sys/dev/cxgbe/common/t4_hw.c  Mon Oct  5 07:26:06 2020
(r366441)
+++ stable/12/sys/dev/cxgbe/common/t4_hw.c  Mon Oct  5 08:51:03 2020
(r366442)
@@ -9627,19 +9627,11 @@ int t4_init_tp_params(struct adapter *adap, bool sleep
 
read_filter_mode_and_ingress_config(adap, sleep_ok);
 
-   /*
-* Cache a mask of the bits that represent the error vector portion of
-* rx_pkt.err_vec.  T6+ can use a compressed error vector to make room
-* for information about outer encapsulation (GENEVE/VXLAN/NVGRE).
-*/
-   tpp->err_vec_mask = htobe16(0x);
if (chip_id(adap) > 

svn commit: r366441 - in stable/12: sbin/ifconfig sys/net

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 07:26:06 2020
New Revision: 366441
URL: https://svnweb.freebsd.org/changeset/base/366441

Log:
  MFC r365868:
  
  Add two new ifnet capabilities for hw checksumming and TSO for VXLAN traffic.
  
  These are similar to the existing VLAN capabilities.
  
  Reviewed by:  kib@
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sbin/ifconfig/ifconfig.8
  stable/12/sbin/ifconfig/ifconfig.c
  stable/12/sbin/ifconfig/ifvxlan.c
  stable/12/sys/net/if.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/ifconfig/ifconfig.8
==
--- stable/12/sbin/ifconfig/ifconfig.8  Mon Oct  5 06:53:29 2020
(r366440)
+++ stable/12/sbin/ifconfig/ifconfig.8  Mon Oct  5 07:26:06 2020
(r366441)
@@ -28,7 +28,7 @@
 .\" From: @(#)ifconfig.8   8.3 (Berkeley) 1/5/94
 .\" $FreeBSD$
 .\"
-.Dd June 4, 2020
+.Dd September 17, 2020
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -559,7 +559,7 @@ If the driver offers user-configurable VLAN support, e
 reception of extended frames, tag processing in hardware,
 frame filtering in hardware, checksum offloading, or TSO on VLAN,
 respectively.
-Note that this must be issued on a physical interface associated with
+Note that this must be configured on a physical interface associated with
 .Xr vlan 4 ,
 not on a
 .Xr vlan 4
@@ -569,6 +569,21 @@ If the driver offers user-configurable VLAN support, d
 reception of extended frames, tag processing in hardware,
 frame filtering in hardware, or TSO on VLAN,
 respectively.
+.It Cm vxlanhwcsum , vxlanhwtso
+If the driver offers user-configurable VXLAN support, enable inner checksum
+offloading (receive and transmit) or TSO on VXLAN, respectively.
+Note that this must be configured on a physical interface associated with
+.Xr vxlan 4 ,
+not on a
+.Xr vxlan 4
+interface itself.
+The physical interface is either the interface specified as the vxlandev
+or the interface hosting the vxlanlocal address.
+The driver will offload as much checksum work and TSO as it can reliably
+support, the exact level of offloading may vary between drivers.
+.It Fl vxlanhwcsum , vxlanhwtso
+If the driver offers user-configurable VXLAN support, disable checksum
+offloading (receive and transmit) or TSO on VXLAN, respectively.
 .It Cm vnet Ar jail
 Move the interface to the
 .Xr jail 8 ,

Modified: stable/12/sbin/ifconfig/ifconfig.c
==
--- stable/12/sbin/ifconfig/ifconfig.c  Mon Oct  5 06:53:29 2020
(r366440)
+++ stable/12/sbin/ifconfig/ifconfig.c  Mon Oct  5 07:26:06 2020
(r366441)
@@ -1344,7 +1344,8 @@ unsetifdescr(const char *val, int value, int s, const 
 "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
 "\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \
 "\17TOE4\20TOE6\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \
-"\26RXCSUM_IPV6\27TXCSUM_IPV6\31TXRTLMT\32HWRXTSTMP"
+"\26RXCSUM_IPV6\27TXCSUM_IPV6\31TXRTLMT\32HWRXTSTMP" \
+"\36VXLAN_HWCSUM\37VXLAN_HWTSO"
 
 /*
  * Print the status of the interface.  If an address family was

Modified: stable/12/sbin/ifconfig/ifvxlan.c
==
--- stable/12/sbin/ifconfig/ifvxlan.c   Mon Oct  5 06:53:29 2020
(r366440)
+++ stable/12/sbin/ifconfig/ifvxlan.c   Mon Oct  5 07:26:06 2020
(r366441)
@@ -620,6 +620,11 @@ static struct cmd vxlan_cmds[] = {
 
DEF_CMD("vxlanflush", 0,setvxlan_flush),
DEF_CMD("vxlanflushall", 1, setvxlan_flush),
+
+   DEF_CMD("vxlanhwcsum",  IFCAP_VXLAN_HWCSUM, setifcap),
+   DEF_CMD("-vxlanhwcsum", -IFCAP_VXLAN_HWCSUM,setifcap),
+   DEF_CMD("vxlanhwtso",   IFCAP_VXLAN_HWTSO,  setifcap),
+   DEF_CMD("-vxlanhwtso",  -IFCAP_VXLAN_HWTSO, setifcap),
 };
 
 static struct afswtch af_vxlan = {

Modified: stable/12/sys/net/if.h
==
--- stable/12/sys/net/if.h  Mon Oct  5 06:53:29 2020(r366440)
+++ stable/12/sys/net/if.h  Mon Oct  5 07:26:06 2020(r366441)
@@ -246,6 +246,8 @@ struct if_data {
 #defineIFCAP_HWSTATS   0x80 /* manages counters internally 
*/
 #defineIFCAP_TXRTLMT   0x100 /* hardware supports TX rate 
limiting */
 #defineIFCAP_HWRXTSTMP 0x200 /* hardware rx timestamping */
+#defineIFCAP_VXLAN_HWCSUM  0x2000 /* can do IFCAN_HWCSUM on 
VXLANs */
+#defineIFCAP_VXLAN_HWTSO   0x4000 /* can do IFCAP_TSO on 
VXLANs */
 
 #define IFCAP_HWCSUM_IPV6  (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6)
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to 

svn commit: r366440 - head/tools/tools/cxgbtool

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 06:53:29 2020
New Revision: 366440
URL: https://svnweb.freebsd.org/changeset/base/366440

Log:
  Get tools/tools/cxgbtool to build with the latest clang.
  
  Reported by:  olivier@

Modified:
  head/tools/tools/cxgbtool/Makefile

Modified: head/tools/tools/cxgbtool/Makefile
==
--- head/tools/tools/cxgbtool/Makefile  Mon Oct  5 06:38:56 2020
(r366439)
+++ head/tools/tools/cxgbtool/Makefile  Mon Oct  5 06:53:29 2020
(r366440)
@@ -6,5 +6,6 @@ MAN=
 CFLAGS+= -I${.CURDIR}/../../../sys/dev/cxgb -I.
 CFLAGS+= -DCONFIG_T3_REGS -DCHELSIO_INTERNAL
 BINDIR?= /usr/sbin
+WARNS?= 3
 
 .include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366439 - stable/12/sys/sys

2020-10-05 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 06:38:56 2020
New Revision: 366439
URL: https://svnweb.freebsd.org/changeset/base/366439

Log:
  MFC r365867:
  
  mbuf checksum flags and fields to support tunneling protocols.
  
  These are being added to support VXLAN but will work for GENEVE as well.
  ENCAP_RSVD1 will likely become ENCAP_GENEVE in the future.
  
  The size of struct mbuf does not change and that means this change can be 
MFC'd.
  If size wasn't a constraint a cleaner way may have been to add 
inner_csum_flags
  and inner_csum_data to go with csum_flags and csum_data.
  
  Reviewed by:  kib@
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D25873

Modified:
  stable/12/sys/sys/mbuf.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/sys/mbuf.h
==
--- stable/12/sys/sys/mbuf.hMon Oct  5 05:36:01 2020(r366438)
+++ stable/12/sys/sys/mbuf.hMon Oct  5 06:38:56 2020(r366439)
@@ -168,7 +168,10 @@ struct pkthdr {
uint8_t  l3hlen;/* layer 3 hdr len */
uint8_t  l4hlen;/* layer 4 hdr len */
uint8_t  l5hlen;/* layer 5 hdr len */
-   uint32_t spare;
+   uint8_t  inner_l2hlen;
+   uint8_t  inner_l3hlen;
+   uint8_t  inner_l4hlen;
+   uint8_t  inner_l5hlen;
};
};
union {
@@ -497,7 +500,13 @@ struct mbuf {
  * Outbound flags that are set by upper protocol layers requesting lower
  * layers, or ideally the hardware, to perform these offloading tasks.
  * For outbound packets this field and its flags can be directly tested
- * against ifnet if_hwassist.
+ * against ifnet if_hwassist.  Note that the outbound and the inbound flags do
+ * not collide right now but they could be allowed to (as long as the flags are
+ * scrubbed appropriately when the direction of an mbuf changes).  CSUM_BITS
+ * would also have to split into CSUM_BITS_TX and CSUM_BITS_RX.
+ *
+ * CSUM_INNER_ is the same as CSUM_ but it applies to the inner frame.
+ * The CSUM_ENCAP_ bits identify the outer encapsulation.
  */
 #defineCSUM_IP 0x0001  /* IP header checksum 
offload */
 #defineCSUM_IP_UDP 0x0002  /* UDP checksum offload 
*/
@@ -506,13 +515,28 @@ struct mbuf {
 #defineCSUM_IP_TSO 0x0010  /* TCP segmentation 
offload */
 #defineCSUM_IP_ISCSI   0x0020  /* iSCSI checksum 
offload */
 
+#defineCSUM_INNER_IP6_UDP  0x0040
+#defineCSUM_INNER_IP6_TCP  0x0080
+#defineCSUM_INNER_IP6_TSO  0x0100
 #defineCSUM_IP6_UDP0x0200  /* UDP checksum offload 
*/
 #defineCSUM_IP6_TCP0x0400  /* TCP checksum offload 
*/
 #defineCSUM_IP6_SCTP   0x0800  /* SCTP checksum 
offload */
 #defineCSUM_IP6_TSO0x1000  /* TCP segmentation 
offload */
 #defineCSUM_IP6_ISCSI  0x2000  /* iSCSI checksum 
offload */
 
+#defineCSUM_INNER_IP   0x4000
+#defineCSUM_INNER_IP_UDP   0x8000
+#defineCSUM_INNER_IP_TCP   0x0001
+#defineCSUM_INNER_IP_TSO   0x0002
+
+#defineCSUM_ENCAP_VXLAN0x0004  /* VXLAN outer 
encapsulation */
+#defineCSUM_ENCAP_RSVD10x0008
+
 /* Inbound checksum support where the checksum was verified by hardware. */
+#defineCSUM_INNER_L3_CALC  0x0010
+#defineCSUM_INNER_L3_VALID 0x0020
+#defineCSUM_INNER_L4_CALC  0x0040
+#defineCSUM_INNER_L4_VALID 0x0080
 #defineCSUM_L3_CALC0x0100  /* calculated layer 3 
csum */
 #defineCSUM_L3_VALID   0x0200  /* checksum is correct 
*/
 #defineCSUM_L4_CALC0x0400  /* calculated layer 4 
csum */
@@ -523,16 +547,31 @@ struct mbuf {
 
 #defineCSUM_SND_TAG0x8000  /* Packet header has 
send tag */
 
+#define CSUM_FLAGS_TX (CSUM_IP | CSUM_IP_UDP | CSUM_IP_TCP | CSUM_IP_SCTP | \
+CSUM_IP_TSO | CSUM_IP_ISCSI | CSUM_INNER_IP6_UDP | CSUM_INNER_IP6_TCP | \
+CSUM_INNER_IP6_TSO | CSUM_IP6_UDP | CSUM_IP6_TCP | CSUM_IP6_SCTP | \
+CSUM_IP6_TSO | CSUM_IP6_ISCSI | CSUM_INNER_IP | CSUM_INNER_IP_UDP | \
+CSUM_INNER_IP_TCP | CSUM_INNER_IP_TSO | CSUM_ENCAP_VXLAN | \
+CSUM_ENCAP_RSVD1 | CSUM_SND_TAG)
+
+#define CSUM_FLAGS_RX (CSUM_INNER_L3_CALC | CSUM_INNER_L3_VALID | \
+CSUM_INNER_L4_CALC | CSUM_INNER_L4_VALID | CSUM_L3_CALC | CSUM_L3_VALID | \
+CSUM_L4_CALC | CSUM_L4_VALID | CSUM_L5_CALC | CSUM_L5_VALID | \
+

svn commit: r366438 - stable/12/sys/dev/cxgbe/tom

2020-10-04 Thread Navdeep Parhar
Author: np
Date: Mon Oct  5 05:36:01 2020
New Revision: 366438
URL: https://svnweb.freebsd.org/changeset/base/366438

Log:
  MFC r366384:
  
  cxgbe(4): set up the firmware flowc for the tid before send_abort_rpl.

Modified:
  stable/12/sys/dev/cxgbe/tom/t4_listen.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/tom/t4_listen.c
==
--- stable/12/sys/dev/cxgbe/tom/t4_listen.c Mon Oct  5 01:27:18 2020
(r366437)
+++ stable/12/sys/dev/cxgbe/tom/t4_listen.c Mon Oct  5 05:36:01 2020
(r366438)
@@ -341,48 +341,32 @@ release_lctx(struct adapter *sc, struct listen_ctx *lc
 }
 
 static void
-send_reset_synqe(struct toedev *tod, struct synq_entry *synqe)
+send_flowc_wr_synqe(struct adapter *sc, struct synq_entry *synqe)
 {
-   struct adapter *sc = tod->tod_softc;
struct mbuf *m = synqe->syn;
struct ifnet *ifp = m->m_pkthdr.rcvif;
struct vi_info *vi = ifp->if_softc;
struct port_info *pi = vi->pi;
-   struct l2t_entry *e = >l2t->l2tab[synqe->params.l2t_idx];
struct wrqe *wr;
struct fw_flowc_wr *flowc;
-   struct cpl_abort_req *req;
-   int flowclen;
struct sge_wrq *ofld_txq;
struct sge_ofld_rxq *ofld_rxq;
const int nparams = 6;
+   const int flowclen = sizeof(*flowc) + nparams * sizeof(struct 
fw_flowc_mnemval);
const u_int pfvf = sc->pf << S_FW_VIID_PFN;
 
INP_WLOCK_ASSERT(synqe->lctx->inp);
+   MPASS((synqe->flags & TPF_FLOWC_WR_SENT) == 0);
 
-   CTR5(KTR_CXGBE, "%s: synqe %p (0x%x), tid %d%s",
-   __func__, synqe, synqe->flags, synqe->tid,
-   synqe->flags & TPF_ABORT_SHUTDOWN ?
-   " (abort already in progress)" : "");
-   if (synqe->flags & TPF_ABORT_SHUTDOWN)
-   return; /* abort already in progress */
-   synqe->flags |= TPF_ABORT_SHUTDOWN;
-
ofld_txq = >sge.ofld_txq[synqe->params.txq_idx];
ofld_rxq = >sge.ofld_rxq[synqe->params.rxq_idx];
 
-   /* The wrqe will have two WRs - a flowc followed by an abort_req */
-   flowclen = sizeof(*flowc) + nparams * sizeof(struct fw_flowc_mnemval);
-
-   wr = alloc_wrqe(roundup2(flowclen, EQ_ESIZE) + sizeof(*req), ofld_txq);
+   wr = alloc_wrqe(roundup2(flowclen, 16), ofld_txq);
if (wr == NULL) {
/* XXX */
panic("%s: allocation failure.", __func__);
}
flowc = wrtod(wr);
-   req = (void *)((caddr_t)flowc + roundup2(flowclen, EQ_ESIZE));
-
-   /* First the flowc ... */
memset(flowc, 0, wr->wr_len);
flowc->op_to_nparams = htobe32(V_FW_WR_OP(FW_FLOWC_WR) |
V_FW_FLOWC_WR_NPARAMS(nparams));
@@ -396,19 +380,47 @@ send_reset_synqe(struct toedev *tod, struct synq_entry
flowc->mnemval[2].val = htobe32(pi->tx_chan);
flowc->mnemval[3].mnemonic = FW_FLOWC_MNEM_IQID;
flowc->mnemval[3].val = htobe32(ofld_rxq->iq.abs_id);
-   flowc->mnemval[4].mnemonic = FW_FLOWC_MNEM_SNDBUF;
-   flowc->mnemval[4].val = htobe32(512);
-   flowc->mnemval[5].mnemonic = FW_FLOWC_MNEM_MSS;
-   flowc->mnemval[5].val = htobe32(512);
+   flowc->mnemval[4].mnemonic = FW_FLOWC_MNEM_SNDBUF;
+   flowc->mnemval[4].val = htobe32(512);
+   flowc->mnemval[5].mnemonic = FW_FLOWC_MNEM_MSS;
+   flowc->mnemval[5].val = htobe32(512);
+
synqe->flags |= TPF_FLOWC_WR_SENT;
+   t4_wrq_tx(sc, wr);
+}
 
-   /* ... then ABORT request */
+static void
+send_reset_synqe(struct toedev *tod, struct synq_entry *synqe)
+{
+   struct adapter *sc = tod->tod_softc;
+   struct wrqe *wr;
+   struct cpl_abort_req *req;
+
+   INP_WLOCK_ASSERT(synqe->lctx->inp);
+
+   CTR5(KTR_CXGBE, "%s: synqe %p (0x%x), tid %d%s",
+   __func__, synqe, synqe->flags, synqe->tid,
+   synqe->flags & TPF_ABORT_SHUTDOWN ?
+   " (abort already in progress)" : "");
+   if (synqe->flags & TPF_ABORT_SHUTDOWN)
+   return; /* abort already in progress */
+   synqe->flags |= TPF_ABORT_SHUTDOWN;
+
+   if (!(synqe->flags & TPF_FLOWC_WR_SENT))
+   send_flowc_wr_synqe(sc, synqe);
+
+   wr = alloc_wrqe(sizeof(*req), >sge.ofld_txq[synqe->params.txq_idx]);
+   if (wr == NULL) {
+   /* XXX */
+   panic("%s: allocation failure.", __func__);
+   }
+   req = wrtod(wr);
INIT_TP_WR_MIT_CPL(req, CPL_ABORT_REQ, synqe->tid);
req->rsvd0 = 0; /* don't have a snd_nxt */
req->rsvd1 = 1; /* no data sent yet */
req->cmd = CPL_ABORT_SEND_RST;
 
-   t4_l2t_send(sc, wr, e);
+   t4_l2t_send(sc, wr, >l2t->l2tab[synqe->params.l2t_idx]);
 }
 
 static int
@@ -888,6 +900,9 @@ do_abort_req_synqe(struct sge_iq *iq, const struct rss
INP_WLOCK(inp);
 
ofld_txq = >sge.ofld_txq[synqe->params.txq_idx];
+
+   if (!(synqe->flags & TPF_FLOWC_WR_SENT))
+  

svn commit: r366384 - head/sys/dev/cxgbe/tom

2020-10-02 Thread Navdeep Parhar
Author: np
Date: Fri Oct  2 23:48:57 2020
New Revision: 366384
URL: https://svnweb.freebsd.org/changeset/base/366384

Log:
  cxgbe(4): set up the firmware flowc for the tid before send_abort_rpl.
  
  MFC after:3 days
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/tom/t4_listen.c

Modified: head/sys/dev/cxgbe/tom/t4_listen.c
==
--- head/sys/dev/cxgbe/tom/t4_listen.c  Fri Oct  2 21:15:49 2020
(r366383)
+++ head/sys/dev/cxgbe/tom/t4_listen.c  Fri Oct  2 23:48:57 2020
(r366384)
@@ -342,48 +342,32 @@ release_lctx(struct adapter *sc, struct listen_ctx *lc
 }
 
 static void
-send_reset_synqe(struct toedev *tod, struct synq_entry *synqe)
+send_flowc_wr_synqe(struct adapter *sc, struct synq_entry *synqe)
 {
-   struct adapter *sc = tod->tod_softc;
struct mbuf *m = synqe->syn;
struct ifnet *ifp = m->m_pkthdr.rcvif;
struct vi_info *vi = ifp->if_softc;
struct port_info *pi = vi->pi;
-   struct l2t_entry *e = >l2t->l2tab[synqe->params.l2t_idx];
struct wrqe *wr;
struct fw_flowc_wr *flowc;
-   struct cpl_abort_req *req;
-   int flowclen;
struct sge_wrq *ofld_txq;
struct sge_ofld_rxq *ofld_rxq;
const int nparams = 6;
+   const int flowclen = sizeof(*flowc) + nparams * sizeof(struct 
fw_flowc_mnemval);
const u_int pfvf = sc->pf << S_FW_VIID_PFN;
 
INP_WLOCK_ASSERT(synqe->lctx->inp);
+   MPASS((synqe->flags & TPF_FLOWC_WR_SENT) == 0);
 
-   CTR5(KTR_CXGBE, "%s: synqe %p (0x%x), tid %d%s",
-   __func__, synqe, synqe->flags, synqe->tid,
-   synqe->flags & TPF_ABORT_SHUTDOWN ?
-   " (abort already in progress)" : "");
-   if (synqe->flags & TPF_ABORT_SHUTDOWN)
-   return; /* abort already in progress */
-   synqe->flags |= TPF_ABORT_SHUTDOWN;
-
ofld_txq = >sge.ofld_txq[synqe->params.txq_idx];
ofld_rxq = >sge.ofld_rxq[synqe->params.rxq_idx];
 
-   /* The wrqe will have two WRs - a flowc followed by an abort_req */
-   flowclen = sizeof(*flowc) + nparams * sizeof(struct fw_flowc_mnemval);
-
-   wr = alloc_wrqe(roundup2(flowclen, EQ_ESIZE) + sizeof(*req), ofld_txq);
+   wr = alloc_wrqe(roundup2(flowclen, 16), ofld_txq);
if (wr == NULL) {
/* XXX */
panic("%s: allocation failure.", __func__);
}
flowc = wrtod(wr);
-   req = (void *)((caddr_t)flowc + roundup2(flowclen, EQ_ESIZE));
-
-   /* First the flowc ... */
memset(flowc, 0, wr->wr_len);
flowc->op_to_nparams = htobe32(V_FW_WR_OP(FW_FLOWC_WR) |
V_FW_FLOWC_WR_NPARAMS(nparams));
@@ -397,19 +381,47 @@ send_reset_synqe(struct toedev *tod, struct synq_entry
flowc->mnemval[2].val = htobe32(pi->tx_chan);
flowc->mnemval[3].mnemonic = FW_FLOWC_MNEM_IQID;
flowc->mnemval[3].val = htobe32(ofld_rxq->iq.abs_id);
-   flowc->mnemval[4].mnemonic = FW_FLOWC_MNEM_SNDBUF;
-   flowc->mnemval[4].val = htobe32(512);
-   flowc->mnemval[5].mnemonic = FW_FLOWC_MNEM_MSS;
-   flowc->mnemval[5].val = htobe32(512);
+   flowc->mnemval[4].mnemonic = FW_FLOWC_MNEM_SNDBUF;
+   flowc->mnemval[4].val = htobe32(512);
+   flowc->mnemval[5].mnemonic = FW_FLOWC_MNEM_MSS;
+   flowc->mnemval[5].val = htobe32(512);
+
synqe->flags |= TPF_FLOWC_WR_SENT;
+   t4_wrq_tx(sc, wr);
+}
 
-   /* ... then ABORT request */
+static void
+send_reset_synqe(struct toedev *tod, struct synq_entry *synqe)
+{
+   struct adapter *sc = tod->tod_softc;
+   struct wrqe *wr;
+   struct cpl_abort_req *req;
+
+   INP_WLOCK_ASSERT(synqe->lctx->inp);
+
+   CTR5(KTR_CXGBE, "%s: synqe %p (0x%x), tid %d%s",
+   __func__, synqe, synqe->flags, synqe->tid,
+   synqe->flags & TPF_ABORT_SHUTDOWN ?
+   " (abort already in progress)" : "");
+   if (synqe->flags & TPF_ABORT_SHUTDOWN)
+   return; /* abort already in progress */
+   synqe->flags |= TPF_ABORT_SHUTDOWN;
+
+   if (!(synqe->flags & TPF_FLOWC_WR_SENT))
+   send_flowc_wr_synqe(sc, synqe);
+
+   wr = alloc_wrqe(sizeof(*req), >sge.ofld_txq[synqe->params.txq_idx]);
+   if (wr == NULL) {
+   /* XXX */
+   panic("%s: allocation failure.", __func__);
+   }
+   req = wrtod(wr);
INIT_TP_WR_MIT_CPL(req, CPL_ABORT_REQ, synqe->tid);
req->rsvd0 = 0; /* don't have a snd_nxt */
req->rsvd1 = 1; /* no data sent yet */
req->cmd = CPL_ABORT_SEND_RST;
 
-   t4_l2t_send(sc, wr, e);
+   t4_l2t_send(sc, wr, >l2t->l2tab[synqe->params.l2t_idx]);
 }
 
 static int
@@ -891,6 +903,9 @@ do_abort_req_synqe(struct sge_iq *iq, const struct rss
INP_WLOCK(inp);
 
ofld_txq = >sge.ofld_txq[synqe->params.txq_idx];
+
+   if (!(synqe->flags & TPF_FLOWC_WR_SENT))
+   

svn commit: r366354 - head/sys/dev/cxgbe

2020-10-02 Thread Navdeep Parhar
Author: np
Date: Fri Oct  2 05:59:55 2020
New Revision: 366354
URL: https://svnweb.freebsd.org/changeset/base/366354

Log:
  cxgbe(4): validate largest_rx_cluster and safest_rx_cluster.
  
  These tunables can only be set to a valid cluster size (2K, 4K, 9K, or
  16K) as documented in the man page.  Anything else could lead to a
  panic on interface up.
  
  Reported by:  mav@
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Fri Oct  2 01:25:08 2020(r366353)
+++ head/sys/dev/cxgbe/t4_sge.c Fri Oct  2 05:59:55 2020(r366354)
@@ -542,6 +542,28 @@ t4_sge_modload(void)
tscale = 1;
}
 
+   if (largest_rx_cluster != MCLBYTES &&
+#if MJUMPAGESIZE != MCLBYTES
+   largest_rx_cluster != MJUMPAGESIZE &&
+#endif
+   largest_rx_cluster != MJUM9BYTES &&
+   largest_rx_cluster != MJUM16BYTES) {
+   printf("Invalid hw.cxgbe.largest_rx_cluster value (%d),"
+   " using %d instead.\n", largest_rx_cluster, MJUM16BYTES);
+   largest_rx_cluster = MJUM16BYTES;
+   }
+
+   if (safest_rx_cluster != MCLBYTES &&
+#if MJUMPAGESIZE != MCLBYTES
+   safest_rx_cluster != MJUMPAGESIZE &&
+#endif
+   safest_rx_cluster != MJUM9BYTES &&
+   safest_rx_cluster != MJUM16BYTES) {
+   printf("Invalid hw.cxgbe.safest_rx_cluster value (%d),"
+   " using %d instead.\n", safest_rx_cluster, MJUMPAGESIZE);
+   safest_rx_cluster = MJUMPAGESIZE;
+   }
+
extfree_refs = counter_u64_alloc(M_WAITOK);
extfree_rels = counter_u64_alloc(M_WAITOK);
pullups = counter_u64_alloc(M_WAITOK);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366274 - stable/12/sys/dev/cxgbe

2020-09-29 Thread Navdeep Parhar
Author: np
Date: Wed Sep 30 00:13:19 2020
New Revision: 366274
URL: https://svnweb.freebsd.org/changeset/base/366274

Log:
  MFC r365991:
  
  cxgbe(4): add counters for mbuf pullups and defrags.

Modified:
  stable/12/sys/dev/cxgbe/t4_sge.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/t4_sge.c
==
--- stable/12/sys/dev/cxgbe/t4_sge.cTue Sep 29 23:48:05 2020
(r366273)
+++ stable/12/sys/dev/cxgbe/t4_sge.cWed Sep 30 00:13:19 2020
(r366274)
@@ -199,6 +199,15 @@ static int lro_mbufs = 0;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, lro_mbufs, CTLFLAG_RDTUN, _mbufs, 0,
 "Enable presorting of LRO frames");
 
+static counter_u64_t pullups;
+SYSCTL_COUNTER_U64(_hw_cxgbe, OID_AUTO, pullups, CTLFLAG_RD, ,
+"Number of mbuf pullups performed");
+
+static counter_u64_t defrags;
+SYSCTL_COUNTER_U64(_hw_cxgbe, OID_AUTO, defrags, CTLFLAG_RD, ,
+"Number of mbuf defrags performed");
+
+
 static int service_iq(struct sge_iq *, int);
 static int service_iq_fl(struct sge_iq *, int);
 static struct mbuf *get_fl_payload(struct adapter *, struct sge_fl *, 
uint32_t);
@@ -529,8 +538,12 @@ t4_sge_modload(void)
 
extfree_refs = counter_u64_alloc(M_WAITOK);
extfree_rels = counter_u64_alloc(M_WAITOK);
+   pullups = counter_u64_alloc(M_WAITOK);
+   defrags = counter_u64_alloc(M_WAITOK);
counter_u64_zero(extfree_refs);
counter_u64_zero(extfree_rels);
+   counter_u64_zero(pullups);
+   counter_u64_zero(defrags);
 
t4_init_shared_cpl_handlers();
t4_register_cpl_handler(CPL_FW4_MSG, handle_fw_msg);
@@ -550,6 +563,8 @@ t4_sge_modunload(void)
 
counter_u64_free(extfree_refs);
counter_u64_free(extfree_rels);
+   counter_u64_free(pullups);
+   counter_u64_free(defrags);
 }
 
 uint64_t
@@ -2460,16 +2475,22 @@ restart:
MPASS(m0->m_pkthdr.len > 0);
nsegs = count_mbuf_nsegs(m0, 0, );
if (nsegs > (needs_tso(m0) ? TX_SGL_SEGS_TSO : TX_SGL_SEGS)) {
-   if (defragged++ > 0 || (m = m_defrag(m0, M_NOWAIT)) == NULL) {
+   if (defragged++ > 0) {
rc = EFBIG;
goto fail;
}
+   counter_u64_add(defrags, 1);
+   if ((m = m_defrag(m0, M_NOWAIT)) == NULL) {
+   rc = ENOMEM;
+   goto fail;
+   }
*mp = m0 = m;   /* update caller's copy after defrag */
goto restart;
}
 
if (__predict_false(nsegs > 2 && m0->m_pkthdr.len <= MHLEN &&
!(cflags & MC_NOMAP))) {
+   counter_u64_add(pullups, 1);
m0 = m_pullup(m0, m0->m_pkthdr.len);
if (m0 == NULL) {
/* Should have left well enough alone. */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366272 - in stable/12/sys/dev/cxgbe: . tom

2020-09-29 Thread Navdeep Parhar
Author: np
Date: Tue Sep 29 23:35:46 2020
New Revision: 366272
URL: https://svnweb.freebsd.org/changeset/base/366272

Log:
  MFC r349533 (by jhb@).
  
  Note that this does not add any functionality as IFCAP_NOMAP doesn't
  exist on 12.  This is mainly an attempt to get t4_sge.c closer to what's
  in head (to help with other MFCs).
  
  r349533:
  Add support for IFCAP_NOMAP to cxgbe(4).
  
  Since cxgbe(4) uses sglist instead of bus_dma, this required updates
  to the code that generates scatter/gather lists for packets.  Also,
  unmapped mbufs are always sent via DMA and never as immediate data in
  the payload of a work request.

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/t4_main.c
  stable/12/sys/dev/cxgbe/t4_sge.c
  stable/12/sys/dev/cxgbe/tom/t4_cpl_io.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Tue Sep 29 23:21:56 2020
(r366271)
+++ stable/12/sys/dev/cxgbe/adapter.h   Tue Sep 29 23:35:46 2020
(r366272)
@@ -82,6 +82,10 @@ prefetch(void *x)
 #define CTLTYPE_U64 CTLTYPE_QUAD
 #endif
 
+#ifndef IFCAP_NOMAP
+#define IFCAP_NOMAP (0)
+#endif
+
 SYSCTL_DECL(_hw_cxgbe);
 
 struct adapter;

Modified: stable/12/sys/dev/cxgbe/t4_main.c
==
--- stable/12/sys/dev/cxgbe/t4_main.c   Tue Sep 29 23:21:56 2020
(r366271)
+++ stable/12/sys/dev/cxgbe/t4_main.c   Tue Sep 29 23:35:46 2020
(r366272)
@@ -1653,7 +1653,7 @@ cxgbe_probe(device_t dev)
 #define T4_CAP (IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | \
 IFCAP_VLAN_HWCSUM | IFCAP_TSO | IFCAP_JUMBO_MTU | IFCAP_LRO | \
 IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWCSUM_IPV6 | IFCAP_HWSTATS | \
-IFCAP_HWRXTSTMP)
+IFCAP_HWRXTSTMP | IFCAP_NOMAP)
 #define T4_CAP_ENABLE (T4_CAP)
 
 static int
@@ -2018,6 +2018,8 @@ cxgbe_ioctl(struct ifnet *ifp, unsigned long cmd, cadd
rxq->iq.flags &= ~IQ_RX_TIMESTAMP;
}
}
+   if (mask & IFCAP_NOMAP)
+   ifp->if_capenable ^= IFCAP_NOMAP;
 
 #ifdef VLAN_CAPABILITIES
VLAN_CAPABILITIES(ifp);

Modified: stable/12/sys/dev/cxgbe/t4_sge.c
==
--- stable/12/sys/dev/cxgbe/t4_sge.cTue Sep 29 23:21:56 2020
(r366271)
+++ stable/12/sys/dev/cxgbe/t4_sge.cTue Sep 29 23:35:46 2020
(r366272)
@@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 /* Internal mbuf flags stored in PH_loc.eight[1]. */
+#defineMC_NOMAP0x01
 #defineMC_RAW_WR   0x02
 
 /*
@@ -2311,15 +2312,80 @@ m_advance(struct mbuf **pm, int *poffset, int len)
return ((void *)p);
 }
 
+#if IFCAP_NOMAP != 0
+static inline int
+count_mbuf_ext_pgs(struct mbuf *m, int skip, vm_paddr_t *nextaddr)
+{
+   struct mbuf_ext_pgs *ext_pgs;
+   vm_paddr_t paddr;
+   int i, len, off, pglen, pgoff, seglen, segoff;
+   int nsegs = 0;
+
+   MBUF_EXT_PGS_ASSERT(m);
+   ext_pgs = m->m_ext.ext_pgs;
+   off = mtod(m, vm_offset_t);
+   len = m->m_len;
+   off += skip;
+   len -= skip;
+
+   if (ext_pgs->hdr_len != 0) {
+   if (off >= ext_pgs->hdr_len) {
+   off -= ext_pgs->hdr_len;
+   } else {
+   seglen = ext_pgs->hdr_len - off;
+   segoff = off;
+   seglen = min(seglen, len);
+   off = 0;
+   len -= seglen;
+   paddr = pmap_kextract(
+   (vm_offset_t)_pgs->hdr[segoff]);
+   if (*nextaddr != paddr)
+   nsegs++;
+   *nextaddr = paddr + seglen;
+   }
+   }
+   pgoff = ext_pgs->first_pg_off;
+   for (i = 0; i < ext_pgs->npgs && len > 0; i++) {
+   pglen = mbuf_ext_pg_len(ext_pgs, i, pgoff);
+   if (off >= pglen) {
+   off -= pglen;
+   pgoff = 0;
+   continue;
+   }
+   seglen = pglen - off;
+   segoff = pgoff + off;
+   off = 0;
+   seglen = min(seglen, len);
+   len -= seglen;
+   paddr = ext_pgs->pa[i] + segoff;
+   if (*nextaddr != paddr)
+   nsegs++;
+   *nextaddr = paddr + seglen;
+   pgoff = 0;
+   };
+   if (len != 0) {
+   seglen = min(len, ext_pgs->trail_len - off);
+   len -= seglen;
+   paddr = pmap_kextract((vm_offset_t)_pgs->trail[off]);
+   if (*nextaddr != paddr)
+   nsegs++;
+ 

svn commit: r366247 - head/sys/dev/cxgbe

2020-09-29 Thread Navdeep Parhar
Author: np
Date: Tue Sep 29 09:25:52 2020
New Revision: 366247
URL: https://svnweb.freebsd.org/changeset/base/366247

Log:
  cxgbe(4): Avoid unnecessary work in the firmware during netmap tx.
  
  Bind the netmap tx queues to a special '0xff' scheduling class which
  makes the firmware skip some processing related to rate limiting on the
  outgoing traffic.  Future firmwares will do this automatically.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_netmap.c

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Tue Sep 29 09:11:51 2020
(r366246)
+++ head/sys/dev/cxgbe/t4_netmap.c  Tue Sep 29 09:25:52 2020
(r366247)
@@ -329,6 +329,22 @@ alloc_nm_txq_hwq(struct vi_info *vi, struct sge_nm_txq
nm_txq->udb = (volatile void *)udb;
}
 
+   if (sc->params.fw_vers < FW_VERSION32(1, 25, 1, 0)) {
+   uint32_t param, val;
+
+   param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
+   V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_EQ_SCHEDCLASS_ETH) 
|
+   V_FW_PARAMS_PARAM_YZ(nm_txq->cntxt_id);
+   val = 0xff;
+   rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, , );
+   if (rc != 0) {
+   device_printf(vi->dev,
+   "failed to bind netmap txq %d to class 0xff: %d\n",
+   nm_txq->cntxt_id, rc);
+   rc = 0;
+   }
+   }
+
return (rc);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366246 - head/sys/dev/cxgbe

2020-09-29 Thread Navdeep Parhar
Author: np
Date: Tue Sep 29 09:11:51 2020
New Revision: 366246
URL: https://svnweb.freebsd.org/changeset/base/366246

Log:
  Remove duplicate line.

Modified:
  head/sys/dev/cxgbe/t4_netmap.c

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Tue Sep 29 07:51:06 2020
(r366245)
+++ head/sys/dev/cxgbe/t4_netmap.c  Tue Sep 29 09:11:51 2020
(r366246)
@@ -216,9 +216,6 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq
param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_CONM_CTXT) |
V_FW_PARAMS_PARAM_YZ(nm_rxq->iq_cntxt_id);
-   param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
-   V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_CONM_CTXT) |
-   V_FW_PARAMS_PARAM_YZ(nm_rxq->iq_cntxt_id);
if (cong == 0)
val = 1 << 19;
else {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366245 - head/sys/dev/cxgbe

2020-09-29 Thread Navdeep Parhar
Author: np
Date: Tue Sep 29 07:51:06 2020
New Revision: 366245
URL: https://svnweb.freebsd.org/changeset/base/366245

Log:
  cxgbe(4): adjust the doorbell threshold for netmap freelists to match the
  maximum burst size used when fetching descriptors from the list.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/t4_netmap.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hTue Sep 29 07:36:21 2020
(r366244)
+++ head/sys/dev/cxgbe/adapter.hTue Sep 29 07:51:06 2020
(r366245)
@@ -730,6 +730,7 @@ struct sge_nm_rxq {
uint32_t fl_sidx2;  /* copy of fl_sidx */
uint32_t fl_db_val;
u_int fl_db_saved;
+   u_int fl_db_threshold;  /* in descriptors */
u_int fl_hwidx:4;
 
/*

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Tue Sep 29 07:36:21 2020
(r366244)
+++ head/sys/dev/cxgbe/t4_netmap.c  Tue Sep 29 07:51:06 2020
(r366245)
@@ -196,6 +196,9 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq
 
nm_rxq->fl_cntxt_id = be16toh(c.fl0id);
nm_rxq->fl_pidx = nm_rxq->fl_cidx = 0;
+   nm_rxq->fl_db_saved = 0;
+   /* matches the X_FETCHBURSTMAX_512B or X_FETCHBURSTMAX_256B above. */
+   nm_rxq->fl_db_threshold = chip_id(sc) <= CHELSIO_T5 ? 8 : 4;
MPASS(nm_rxq->fl_sidx == na->num_rx_desc);
cntxt_id = nm_rxq->fl_cntxt_id - sc->sge.eq_start;
if (cntxt_id >= sc->sge.neq) {
@@ -1063,7 +1066,7 @@ cxgbe_netmap_rxsync(struct netmap_kring *kring, int fl
fl_pidx = 0;
slot = >slot[0];
}
-   if (++dbinc == 8 && n >= 32) {
+   if (++dbinc == nm_rxq->fl_db_threshold) {
wmb();
if (starve_fl)
nm_rxq->fl_db_saved += dbinc;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366244 - head/sys/dev/cxgbe

2020-09-29 Thread Navdeep Parhar
Author: np
Date: Tue Sep 29 07:36:21 2020
New Revision: 366244
URL: https://svnweb.freebsd.org/changeset/base/366244

Log:
  cxgbe(4): display an error message when netmap cannot be enabled because
  the interface is down.
  
  MFC after:1 week

Modified:
  head/sys/dev/cxgbe/t4_netmap.c

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Tue Sep 29 05:49:45 2020
(r366243)
+++ head/sys/dev/cxgbe/t4_netmap.c  Tue Sep 29 07:36:21 2020
(r366244)
@@ -536,8 +536,11 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi
MPASS(vi->nnmtxq > 0);
 
if ((vi->flags & VI_INIT_DONE) == 0 ||
-   (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+   (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+   if_printf(ifp, "cannot enable netmap operation because "
+   "interface is not UP.\n");
return (EAGAIN);
+   }
 
rxb = >sge.rx_buf_info[0];
for (i = 0; i < SW_ZONE_SIZES; i++, rxb++) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366242 - head/sys/dev/cxgbe

2020-09-28 Thread Navdeep Parhar
Author: np
Date: Tue Sep 29 05:08:45 2020
New Revision: 366242
URL: https://svnweb.freebsd.org/changeset/base/366242

Log:
  cxgbe(4): fixes for netmap operation with only some queues active.
  
  - Only active netmap receive queues should be in the RSS lookup table.
  
  - The RSS table should be restored for NIC operation when the last
active netmap queue is switched off, not the first one.
  
  - Support repeated netmap ON/OFF on a subset of the queues.  This works
whether the the queues being enabled and disabled are the only ones
active or not.  Some kring indexes have to be reset in the driver for
the second case.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_netmap.c

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Tue Sep 29 02:03:24 2020
(r366241)
+++ head/sys/dev/cxgbe/t4_netmap.c  Tue Sep 29 05:08:45 2020
(r366242)
@@ -347,6 +347,180 @@ free_nm_txq_hwq(struct vi_info *vi, struct sge_nm_txq 
 }
 
 static int
+cxgbe_netmap_simple_rss(struct adapter *sc, struct vi_info *vi,
+struct ifnet *ifp, struct netmap_adapter *na)
+{
+   struct netmap_kring *kring;
+   struct sge_nm_rxq *nm_rxq;
+   int rc, i, j, nm_state, defq;
+   uint16_t *rss;
+
+   /*
+* Check if there's at least one active (or about to go active) netmap
+* rx queue.
+*/
+   defq = -1;
+   for_each_nm_rxq(vi, j, nm_rxq) {
+   nm_state = atomic_load_int(_rxq->nm_state);
+   kring = na->rx_rings[nm_rxq->nid];
+   if ((nm_state != NM_OFF && !nm_kring_pending_off(kring)) ||
+   (nm_state == NM_OFF && nm_kring_pending_on(kring))) {
+   MPASS(nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID);
+   if (defq == -1) {
+   defq = nm_rxq->iq_abs_id;
+   break;
+   }
+   }
+   }
+
+   if (defq == -1) {
+   /* No active netmap queues.  Switch back to NIC queues. */
+   rss = vi->rss;
+   defq = vi->rss[0];
+   } else {
+   for (i = 0; i < vi->rss_size;) {
+   for_each_nm_rxq(vi, j, nm_rxq) {
+   nm_state = atomic_load_int(_rxq->nm_state);
+   kring = na->rx_rings[nm_rxq->nid];
+   if ((nm_state != NM_OFF &&
+   !nm_kring_pending_off(kring)) ||
+   (nm_state == NM_OFF &&
+   nm_kring_pending_on(kring))) {
+   MPASS(nm_rxq->iq_cntxt_id !=
+   INVALID_NM_RXQ_CNTXT_ID);
+   vi->nm_rss[i++] = nm_rxq->iq_abs_id;
+   if (i == vi->rss_size)
+   break;
+   }
+   }
+   }
+   rss = vi->nm_rss;
+   }
+
+   rc = -t4_config_rss_range(sc, sc->mbox, vi->viid, 0, vi->rss_size, rss,
+   vi->rss_size);
+   if (rc != 0)
+   if_printf(ifp, "netmap rss_config failed: %d\n", rc);
+
+   rc = -t4_config_vi_rss(sc, sc->mbox, vi->viid, vi->hashen, defq, 0, 0);
+   if (rc != 0) {
+   if_printf(ifp, "netmap defaultq config failed: %d\n", rc);
+   }
+
+   return (rc);
+}
+
+/*
+ * Odd number of rx queues work best for split RSS mode as the first queue can
+ * be dedicated for non-RSS traffic and the rest divided into two equal halves.
+ */
+static int
+cxgbe_netmap_split_rss(struct adapter *sc, struct vi_info *vi,
+struct ifnet *ifp, struct netmap_adapter *na)
+{
+   struct netmap_kring *kring;
+   struct sge_nm_rxq *nm_rxq;
+   int rc, i, j, nm_state, defq;
+   int nactive[2] = {0, 0};
+   int dq[2] = {-1, -1};
+   bool dq_norss;  /* default queue should not be in RSS table. */
+
+   MPASS(nm_split_rss != 0);
+   MPASS(vi->nnmrxq > 1);
+
+   for_each_nm_rxq(vi, i, nm_rxq) {
+   j = i / ((vi->nnmrxq + 1) / 2);
+   nm_state = atomic_load_int(_rxq->nm_state);
+   kring = na->rx_rings[nm_rxq->nid];
+   if ((nm_state != NM_OFF && !nm_kring_pending_off(kring)) ||
+   (nm_state == NM_OFF && nm_kring_pending_on(kring))) {
+   MPASS(nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID);
+   nactive[j]++;
+   if (dq[j] == -1) {
+   dq[j] = nm_rxq->iq_abs_id;
+   break;
+   }
+   }
+   }
+
+   if (nactive[0] == 0 || nactive[1] == 0)

svn commit: r365993 - in head: share/man/man4 sys/dev/cxgbe

2020-09-21 Thread Navdeep Parhar
Author: np
Date: Tue Sep 22 04:16:40 2020
New Revision: 365993
URL: https://svnweb.freebsd.org/changeset/base/365993

Log:
  cxgbe(4): let the PF driver use VM work requests for transmit.
  
  This allows the PF interfaces to communicate with the VF interfaces over
  the internal switch in the ASIC.  Fix the GL limits for VM work requests
  while here.
  
  MFC after:3 days
  Sponsored by: Chelsio Communications

Modified:
  head/share/man/man4/cxgbe.4
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/share/man/man4/cxgbe.4
==
--- head/share/man/man4/cxgbe.4 Tue Sep 22 03:57:48 2020(r365992)
+++ head/share/man/man4/cxgbe.4 Tue Sep 22 04:16:40 2020(r365993)
@@ -351,6 +351,17 @@ This tunable is for specialized applications only and 
 normal operation.
 The capabilities for which hardware resources have been reserved are listed in
 dev..X.*caps sysctls.
+.It Va hw.cxgbe.tx_vm_wr
+Setting this to 1 instructs the driver to use VM work requests to transmit 
data.
+This lets PF interfaces transmit frames to VF interfaces over the internal
+switch in the ASIC.
+Note that the
+.Xr cxgbev 4
+VF driver always uses VM work requests and is not affected by this tunable.
+The default value is 0 and should be changed only if PF and VF interfaces need
+to communicate with each other.
+Different interfaces can be assigned different values using the
+dev..X.tx_vm_wr sysctl when the interface is administratively down.
 .El
 .Sh SUPPORT
 For general information and support,

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hTue Sep 22 03:57:48 2020
(r365992)
+++ head/sys/dev/cxgbe/adapter.hTue Sep 22 04:16:40 2020
(r365993)
@@ -118,6 +118,8 @@ enum {
SGE_MAX_WR_NDESC = SGE_MAX_WR_LEN / EQ_ESIZE, /* max WR size in desc */
TX_SGL_SEGS = 39,
TX_SGL_SEGS_TSO = 38,
+   TX_SGL_SEGS_VM = 38,
+   TX_SGL_SEGS_VM_TSO = 37,
TX_SGL_SEGS_EO_TSO = 30,/* XXX: lower for IPv6. */
TX_SGL_SEGS_VXLAN_TSO = 37,
TX_WR_FLITS = SGE_MAX_WR_LEN / 8
@@ -173,6 +175,7 @@ enum {
DOOMED  = (1 << 0),
VI_INIT_DONE= (1 << 1),
VI_SYSCTL_CTX   = (1 << 2),
+   TX_USES_VM_WR   = (1 << 3),
 
/* adapter debug_flags */
DF_DUMP_MBOX= (1 << 0), /* Log all mbox cmd/rpl. */
@@ -1267,7 +1270,7 @@ void t4_intr_evt(void *);
 void t4_wrq_tx_locked(struct adapter *, struct sge_wrq *, struct wrqe *);
 void t4_update_fl_bufsize(struct ifnet *);
 struct mbuf *alloc_wr_mbuf(int, int);
-int parse_pkt(struct adapter *, struct mbuf **);
+int parse_pkt(struct mbuf **, bool);
 void *start_wrq_wr(struct sge_wrq *, int, struct wrq_cookie *);
 void commit_wrq_wr(struct sge_wrq *, void *, struct wrq_cookie *);
 int tnl_cong(struct port_info *, int);

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cTue Sep 22 03:57:48 2020
(r365992)
+++ head/sys/dev/cxgbe/t4_main.cTue Sep 22 04:16:40 2020
(r365993)
@@ -591,6 +591,10 @@ static int t4_panic_on_fatal_err = 0;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, panic_on_fatal_err, CTLFLAG_RDTUN,
 _panic_on_fatal_err, 0, "panic on fatal errors");
 
+static int t4_tx_vm_wr = 0;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, tx_vm_wr, CTLFLAG_RWTUN, _tx_vm_wr, 0,
+"Use VM work requests to transmit packets.");
+
 #ifdef TCP_OFFLOAD
 /*
  * TOE tunables.
@@ -695,6 +699,7 @@ static int sysctl_bitfield_8b(SYSCTL_HANDLER_ARGS);
 static int sysctl_bitfield_16b(SYSCTL_HANDLER_ARGS);
 static int sysctl_btphy(SYSCTL_HANDLER_ARGS);
 static int sysctl_noflowq(SYSCTL_HANDLER_ARGS);
+static int sysctl_tx_vm_wr(SYSCTL_HANDLER_ARGS);
 static int sysctl_holdoff_tmr_idx(SYSCTL_HANDLER_ARGS);
 static int sysctl_holdoff_pktc_idx(SYSCTL_HANDLER_ARGS);
 static int sysctl_qsize_rxq(SYSCTL_HANDLER_ARGS);
@@ -1723,6 +1728,8 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
 
vi->xact_addr_filt = -1;
callout_init(>tick, 1);
+   if (sc->flags & IS_VF || t4_tx_vm_wr != 0)
+   vi->flags |= TX_USES_VM_WR;
 
/* Allocate an ifnet and set it up */
ifp = if_alloc_dev(IFT_ETHER, dev);
@@ -1775,7 +1782,10 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
 #endif
 
ifp->if_hw_tsomax = IP_MAXPACKET;
-   ifp->if_hw_tsomaxsegcount = TX_SGL_SEGS_TSO;
+   if (vi->flags & TX_USES_VM_WR)
+   ifp->if_hw_tsomaxsegcount = TX_SGL_SEGS_VM_TSO;
+   else
+   ifp->if_hw_tsomaxsegcount = TX_SGL_SEGS_TSO;
 #ifdef RATELIMIT
if (is_ethoffload(sc) && vi->nofldtxq != 0)
ifp->if_hw_tsomaxsegcount = TX_SGL_SEGS_EO_TSO;
@@ -2174,7 +2184,7 @@ cxgbe_transmit(struct 

svn commit: r365991 - head/sys/dev/cxgbe

2020-09-21 Thread Navdeep Parhar
Author: np
Date: Tue Sep 22 03:06:36 2020
New Revision: 365991
URL: https://svnweb.freebsd.org/changeset/base/365991

Log:
  cxgbe(4): add counters for mbuf pullups and defrags.
  
  MFC after:3 days
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Tue Sep 22 02:22:37 2020(r365990)
+++ head/sys/dev/cxgbe/t4_sge.c Tue Sep 22 03:06:36 2020(r365991)
@@ -204,6 +204,15 @@ static int lro_mbufs = 0;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, lro_mbufs, CTLFLAG_RDTUN, _mbufs, 0,
 "Enable presorting of LRO frames");
 
+static counter_u64_t pullups;
+SYSCTL_COUNTER_U64(_hw_cxgbe, OID_AUTO, pullups, CTLFLAG_RD, ,
+"Number of mbuf pullups performed");
+
+static counter_u64_t defrags;
+SYSCTL_COUNTER_U64(_hw_cxgbe, OID_AUTO, defrags, CTLFLAG_RD, ,
+"Number of mbuf defrags performed");
+
+
 static int service_iq(struct sge_iq *, int);
 static int service_iq_fl(struct sge_iq *, int);
 static struct mbuf *get_fl_payload(struct adapter *, struct sge_fl *, 
uint32_t);
@@ -535,8 +544,12 @@ t4_sge_modload(void)
 
extfree_refs = counter_u64_alloc(M_WAITOK);
extfree_rels = counter_u64_alloc(M_WAITOK);
+   pullups = counter_u64_alloc(M_WAITOK);
+   defrags = counter_u64_alloc(M_WAITOK);
counter_u64_zero(extfree_refs);
counter_u64_zero(extfree_rels);
+   counter_u64_zero(pullups);
+   counter_u64_zero(defrags);
 
t4_init_shared_cpl_handlers();
t4_register_cpl_handler(CPL_FW4_MSG, handle_fw_msg);
@@ -556,6 +569,8 @@ t4_sge_modunload(void)
 
counter_u64_free(extfree_refs);
counter_u64_free(extfree_rels);
+   counter_u64_free(pullups);
+   counter_u64_free(defrags);
 }
 
 uint64_t
@@ -2714,16 +2729,22 @@ restart:
}
 #endif
if (nsegs > max_nsegs_allowed(m0)) {
-   if (defragged++ > 0 || (m = m_defrag(m0, M_NOWAIT)) == NULL) {
+   if (defragged++ > 0) {
rc = EFBIG;
goto fail;
}
+   counter_u64_add(defrags, 1);
+   if ((m = m_defrag(m0, M_NOWAIT)) == NULL) {
+   rc = ENOMEM;
+   goto fail;
+   }
*mp = m0 = m;   /* update caller's copy after defrag */
goto restart;
}
 
if (__predict_false(nsegs > 2 && m0->m_pkthdr.len <= MHLEN &&
!(cflags & MC_NOMAP))) {
+   counter_u64_add(pullups, 1);
m0 = m_pullup(m0, m0->m_pkthdr.len);
if (m0 == NULL) {
/* Should have left well enough alone. */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365961 - in releng/12.2/sys: conf dev/cxgbe/firmware modules/cxgbe/t4_firmware modules/cxgbe/t5_firmware modules/cxgbe/t6_firmware

2020-09-21 Thread Navdeep Parhar
Author: np
Date: Mon Sep 21 18:19:48 2020
New Revision: 365961
URL: https://svnweb.freebsd.org/changeset/base/365961

Log:
  MFS r365937, which merged r365861 and r365872 from head to stable/12.
  
  r365861:
  cxgbe(4): Update T4/5/6 firmwares to 1.25.0.0.
  
  r365872:
  cxgbe(4): add the firmware binaries instead of the empty files that were added
  in r365861.
  
  Approved by:  re@ (gjb@)

Added:
  releng/12.2/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin
 - copied unchanged from r365937, 
stable/12/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin
  releng/12.2/sys/dev/cxgbe/firmware/t5fw-1.25.0.0.bin
 - copied unchanged from r365937, 
stable/12/sys/dev/cxgbe/firmware/t5fw-1.25.0.0.bin
  releng/12.2/sys/dev/cxgbe/firmware/t6fw-1.25.0.0.bin
 - copied unchanged from r365937, 
stable/12/sys/dev/cxgbe/firmware/t6fw-1.25.0.0.bin
Deleted:
  releng/12.2/sys/dev/cxgbe/firmware/t4fw-1.24.12.0.bin
  releng/12.2/sys/dev/cxgbe/firmware/t5fw-1.24.12.0.bin
  releng/12.2/sys/dev/cxgbe/firmware/t6fw-1.24.12.0.bin
Modified:
  releng/12.2/sys/conf/files
  releng/12.2/sys/dev/cxgbe/firmware/t4fw_interface.h
  releng/12.2/sys/dev/cxgbe/firmware/t6fw_cfg.txt
  releng/12.2/sys/dev/cxgbe/firmware/t6fw_cfg_uwire.txt
  releng/12.2/sys/modules/cxgbe/t4_firmware/Makefile
  releng/12.2/sys/modules/cxgbe/t5_firmware/Makefile
  releng/12.2/sys/modules/cxgbe/t6_firmware/Makefile
Directory Properties:
  releng/12.2/   (props changed)

Modified: releng/12.2/sys/conf/files
==
--- releng/12.2/sys/conf/files  Mon Sep 21 18:19:35 2020(r365960)
+++ releng/12.2/sys/conf/files  Mon Sep 21 18:19:48 2020(r365961)
@@ -1476,7 +1476,7 @@ t4fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t4fw.fwo"
 t4fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t4fw-1.24.12.0.bin"  \
+   dependency  "$S/dev/cxgbe/firmware/t4fw-1.25.0.0.bin"   \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t4fw.fw"
@@ -1510,7 +1510,7 @@ t5fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t5fw.fwo"
 t5fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t5fw-1.24.12.0.bin"  \
+   dependency  "$S/dev/cxgbe/firmware/t5fw-1.25.0.0.bin"   \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t5fw.fw"
@@ -1544,7 +1544,7 @@ t6fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t6fw.fwo"
 t6fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t6fw-1.24.12.0.bin"  \
+   dependency  "$S/dev/cxgbe/firmware/t6fw-1.25.0.0.bin"   \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t6fw.fw"

Copied: releng/12.2/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin (from r365937, 
stable/12/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin)
==
Binary file (source and/or target). No diff available.

Modified: releng/12.2/sys/dev/cxgbe/firmware/t4fw_interface.h
==
--- releng/12.2/sys/dev/cxgbe/firmware/t4fw_interface.h Mon Sep 21 18:19:35 
2020(r365960)
+++ releng/12.2/sys/dev/cxgbe/firmware/t4fw_interface.h Mon Sep 21 18:19:48 
2020(r365961)
@@ -4690,6 +4690,7 @@ enum fw_caps_config_crypto {
FW_CAPS_CONFIG_CRYPTO_LOOKASIDE = 0x0001,
FW_CAPS_CONFIG_TLSKEYS = 0x0002,
FW_CAPS_CONFIG_IPSEC_INLINE = 0x0004,
+   FW_CAPS_CONFIG_TLS_HW = 0x0008,
 };
 
 enum fw_caps_config_fcoe {
@@ -4838,6 +4839,7 @@ enum fw_params_param_dev {
FW_PARAMS_PARAM_DEV_TCB_CACHE_FLUSH = 0x2D,
FW_PARAMS_PARAM_DEV_FILTER = 0x2E,
FW_PARAMS_PARAM_DEV_CLIP2_CMD = 0x2F,
+   FW_PARAMS_PARAM_DEV_KTLS_HW = 0x31,
 };
 
 /*
@@ -4874,6 +4876,13 @@ enum fw_params_param_dev_filter{
FW_PARAM_DEV_FILTER_MODE_MASK   = 0x01,
 };
 
+enum fw_params_param_dev_ktls_hw {
+   FW_PARAMS_PARAM_DEV_KTLS_HW_DISABLE = 0x00,
+   FW_PARAMS_PARAM_DEV_KTLS_HW_ENABLE  = 0x01,
+   FW_PARAMS_PARAM_DEV_KTLS_HW_USER_DISABLE = 0x00,
+   

svn commit: r365937 - in stable/12/sys: conf dev/cxgbe/firmware modules/cxgbe/t4_firmware modules/cxgbe/t5_firmware modules/cxgbe/t6_firmware

2020-09-21 Thread Navdeep Parhar
Author: np
Date: Mon Sep 21 08:16:42 2020
New Revision: 365937
URL: https://svnweb.freebsd.org/changeset/base/365937

Log:
  MFC r365861 and r365872.
  
  r365861:
  cxgbe(4): Update T4/5/6 firmwares to 1.25.0.0.
  
  r365872:
  cxgbe(4): add the firmware binaries instead of the empty files that were added
  in r365861.
  
  Obtained from:Chelsio Communications
  Sponsored by: Chelsio Communications

Added:
  stable/12/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin   (contents, props changed)
 - copied, changed from r365861, 
head/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin
  stable/12/sys/dev/cxgbe/firmware/t5fw-1.25.0.0.bin   (contents, props changed)
 - copied, changed from r365861, 
head/sys/dev/cxgbe/firmware/t5fw-1.25.0.0.bin
  stable/12/sys/dev/cxgbe/firmware/t6fw-1.25.0.0.bin   (contents, props changed)
 - copied, changed from r365861, 
head/sys/dev/cxgbe/firmware/t6fw-1.25.0.0.bin
Deleted:
  stable/12/sys/dev/cxgbe/firmware/t4fw-1.24.12.0.bin
  stable/12/sys/dev/cxgbe/firmware/t5fw-1.24.12.0.bin
  stable/12/sys/dev/cxgbe/firmware/t6fw-1.24.12.0.bin
Modified:
  stable/12/sys/conf/files
  stable/12/sys/dev/cxgbe/firmware/t4fw_interface.h
  stable/12/sys/dev/cxgbe/firmware/t6fw_cfg.txt
  stable/12/sys/dev/cxgbe/firmware/t6fw_cfg_uwire.txt
  stable/12/sys/modules/cxgbe/t4_firmware/Makefile
  stable/12/sys/modules/cxgbe/t5_firmware/Makefile
  stable/12/sys/modules/cxgbe/t6_firmware/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/conf/files
==
--- stable/12/sys/conf/filesMon Sep 21 03:16:10 2020(r365936)
+++ stable/12/sys/conf/filesMon Sep 21 08:16:42 2020(r365937)
@@ -1476,7 +1476,7 @@ t4fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t4fw.fwo"
 t4fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t4fw-1.24.12.0.bin"  \
+   dependency  "$S/dev/cxgbe/firmware/t4fw-1.25.0.0.bin"   \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t4fw.fw"
@@ -1510,7 +1510,7 @@ t5fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t5fw.fwo"
 t5fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t5fw-1.24.12.0.bin"  \
+   dependency  "$S/dev/cxgbe/firmware/t5fw-1.25.0.0.bin"   \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t5fw.fw"
@@ -1544,7 +1544,7 @@ t6fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t6fw.fwo"
 t6fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t6fw-1.24.12.0.bin"  \
+   dependency  "$S/dev/cxgbe/firmware/t6fw-1.25.0.0.bin"   \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t6fw.fw"

Copied and modified: stable/12/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin (from 
r365861, head/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin)
==
Binary file (source and/or target). No diff available.

Modified: stable/12/sys/dev/cxgbe/firmware/t4fw_interface.h
==
--- stable/12/sys/dev/cxgbe/firmware/t4fw_interface.h   Mon Sep 21 03:16:10 
2020(r365936)
+++ stable/12/sys/dev/cxgbe/firmware/t4fw_interface.h   Mon Sep 21 08:16:42 
2020(r365937)
@@ -4690,6 +4690,7 @@ enum fw_caps_config_crypto {
FW_CAPS_CONFIG_CRYPTO_LOOKASIDE = 0x0001,
FW_CAPS_CONFIG_TLSKEYS = 0x0002,
FW_CAPS_CONFIG_IPSEC_INLINE = 0x0004,
+   FW_CAPS_CONFIG_TLS_HW = 0x0008,
 };
 
 enum fw_caps_config_fcoe {
@@ -4838,6 +4839,7 @@ enum fw_params_param_dev {
FW_PARAMS_PARAM_DEV_TCB_CACHE_FLUSH = 0x2D,
FW_PARAMS_PARAM_DEV_FILTER = 0x2E,
FW_PARAMS_PARAM_DEV_CLIP2_CMD = 0x2F,
+   FW_PARAMS_PARAM_DEV_KTLS_HW = 0x31,
 };
 
 /*
@@ -4874,6 +4876,13 @@ enum fw_params_param_dev_filter{
FW_PARAM_DEV_FILTER_MODE_MASK   = 0x01,
 };
 
+enum fw_params_param_dev_ktls_hw {
+   FW_PARAMS_PARAM_DEV_KTLS_HW_DISABLE = 0x00,
+   FW_PARAMS_PARAM_DEV_KTLS_HW_ENABLE  = 0x01,
+   

svn commit: r365872 - head/sys/dev/cxgbe/firmware

2020-09-17 Thread Navdeep Parhar
Author: np
Date: Fri Sep 18 03:11:47 2020
New Revision: 365872
URL: https://svnweb.freebsd.org/changeset/base/365872

Log:
  cxgbe(4): add the firmware binaries instead of the empty files that were added
  in r365861.
  
  Obtained from:Chelsio Communications
  MFC after:3 days
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin   (contents, props changed)
  head/sys/dev/cxgbe/firmware/t5fw-1.25.0.0.bin   (contents, props changed)
  head/sys/dev/cxgbe/firmware/t6fw-1.25.0.0.bin   (contents, props changed)

Modified: head/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/dev/cxgbe/firmware/t5fw-1.25.0.0.bin
==
Binary file (source and/or target). No diff available.

Modified: head/sys/dev/cxgbe/firmware/t6fw-1.25.0.0.bin
==
Binary file (source and/or target). No diff available.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365871 - in head: share/man/man4 sys/dev/cxgbe sys/dev/cxgbe/common sys/dev/cxgbe/firmware

2020-09-17 Thread Navdeep Parhar
Author: np
Date: Fri Sep 18 03:01:47 2020
New Revision: 365871
URL: https://svnweb.freebsd.org/changeset/base/365871

Log:
  cxgbe(4): add support for stateless offloads for VXLAN traffic.
  
  Hardware assistance includes checksumming (tx and rx), TSO, and RSS on
  the inner traffic in a VXLAN tunnel.
  
  Relnotes: Yes
  Sponsored by: Chelsio Communications

Modified:
  head/share/man/man4/cxgbe.4
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/common/common.h
  head/sys/dev/cxgbe/common/t4_hw.c
  head/sys/dev/cxgbe/firmware/t6fw_cfg.txt
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/share/man/man4/cxgbe.4
==
--- head/share/man/man4/cxgbe.4 Fri Sep 18 02:37:57 2020(r365870)
+++ head/share/man/man4/cxgbe.4 Fri Sep 18 03:01:47 2020(r365871)
@@ -31,7 +31,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd Dec 10, 2019
+.Dd September 17, 2020
 .Dt CXGBE 4
 .Os
 .Sh NAME
@@ -61,8 +61,8 @@ driver provides support for PCI Express Ethernet adapt
 the Chelsio Terminator 4, Terminator 5, and Terminator 6 ASICs (T4, T5, and 
T6).
 The driver supports Jumbo Frames, Transmit/Receive checksum offload,
 TCP segmentation offload (TSO), Large Receive Offload (LRO), VLAN
-tag insertion/extraction, VLAN checksum offload, VLAN TSO, and
-Receive Side Steering (RSS).
+tag insertion/extraction, VLAN checksum offload, VLAN TSO, VXLAN checksum
+offload, VXLAN TSO, and Receive Side Steering (RSS).
 For further hardware information and questions related to hardware
 requirements, see
 .Pa http://www.chelsio.com/ .

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hFri Sep 18 02:37:57 2020
(r365870)
+++ head/sys/dev/cxgbe/adapter.hFri Sep 18 03:01:47 2020
(r365871)
@@ -119,6 +119,7 @@ enum {
TX_SGL_SEGS = 39,
TX_SGL_SEGS_TSO = 38,
TX_SGL_SEGS_EO_TSO = 30,/* XXX: lower for IPv6. */
+   TX_SGL_SEGS_VXLAN_TSO = 37,
TX_WR_FLITS = SGE_MAX_WR_LEN / 8
 };
 
@@ -286,6 +287,7 @@ struct port_info {
int nvi;
int up_vis;
int uld_vis;
+   bool vxlan_tcam_entry;
 
struct tx_sched_params *sched_params;
 
@@ -593,6 +595,8 @@ struct sge_txq {
uint64_t txpkts0_pkts;  /* # of frames in type0 coalesced tx WRs */
uint64_t txpkts1_pkts;  /* # of frames in type1 coalesced tx WRs */
uint64_t raw_wrs;   /* # of raw work requests (alloc_wr_mbuf) */
+   uint64_t vxlan_tso_wrs; /* # of VXLAN TSO work requests */
+   uint64_t vxlan_txcsum;
 
uint64_t kern_tls_records;
uint64_t kern_tls_short;
@@ -625,6 +629,7 @@ struct sge_rxq {
 
uint64_t rxcsum;/* # of times hardware assisted with checksum */
uint64_t vlan_extraction;/* # of times VLAN tag was extracted */
+   uint64_t vxlan_rxcsum;
 
/* stats for not-that-common events */
 
@@ -847,6 +852,11 @@ struct adapter {
struct sge sge;
int lro_timeout;
int sc_do_rxcopy;
+
+   int vxlan_port;
+   u_int vxlan_refcount;
+   int rawf_base;
+   int nrawf;
 
struct taskqueue *tq[MAX_NCHAN];/* General purpose taskqueues */
struct task async_event_task;

Modified: head/sys/dev/cxgbe/common/common.h
==
--- head/sys/dev/cxgbe/common/common.h  Fri Sep 18 02:37:57 2020
(r365870)
+++ head/sys/dev/cxgbe/common/common.h  Fri Sep 18 03:01:47 2020
(r365871)
@@ -249,7 +249,7 @@ struct tp_params {
uint32_t max_rx_pdu;
uint32_t max_tx_pdu;
uint64_t hash_filter_mask;
-   __be16 err_vec_mask;
+   bool rx_pkt_encap;
 
int8_t fcoe_shift;
int8_t port_shift;

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Fri Sep 18 02:37:57 2020
(r365870)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Fri Sep 18 03:01:47 2020
(r365871)
@@ -9647,19 +9647,11 @@ int t4_init_tp_params(struct adapter *adap, bool sleep
 
read_filter_mode_and_ingress_config(adap, sleep_ok);
 
-   /*
-* Cache a mask of the bits that represent the error vector portion of
-* rx_pkt.err_vec.  T6+ can use a compressed error vector to make room
-* for information about outer encapsulation (GENEVE/VXLAN/NVGRE).
-*/
-   tpp->err_vec_mask = htobe16(0x);
if (chip_id(adap) > CHELSIO_T5) {
v = t4_read_reg(adap, A_TP_OUT_CONFIG);
-   if (v & F_CRXPKTENC) {
-   tpp->err_vec_mask =
-   htobe16(V_T6_COMPR_RXERR_VEC(M_T6_COMPR_RXERR_VEC));
-   }
-   }
+   tpp->rx_pkt_encap = v & F_CRXPKTENC;
+   } else
+ 

svn commit: r365870 - in head: share/man/man4 share/man/man9 sys/net sys/netinet sys/netinet6

2020-09-17 Thread Navdeep Parhar
Author: np
Date: Fri Sep 18 02:37:57 2020
New Revision: 365870
URL: https://svnweb.freebsd.org/changeset/base/365870

Log:
  if_vxlan(4): add support for hardware assisted checksumming, TSO, and RSS.
  
  This lets a VXLAN pseudo-interface take advantage of hardware checksumming (tx
  and rx), TSO, and RSS if the NIC is capable of performing these operations on
  inner VXLAN traffic.
  
  A VXLAN interface inherits the capabilities of its vxlandev interface if one 
is
  specified or of the interface that hosts the vxlanlocal address. If other
  interfaces will carry traffic for that VXLAN then they must have the same
  hardware capabilities.
  
  On transmit, if_vxlan verifies that the outbound interface has the required
  capabilities and then translates the CSUM_ flags to their inner equivalents.
  This tells the hardware ifnet that it needs to operate on the inner frame and
  not the outer VXLAN headers.
  
  An event is generated when a VXLAN ifnet starts. This allows hardware drivers 
to
  configure their devices to expect VXLAN traffic on the specified incoming 
port.
  
  On receive, the hardware does RSS and checksum verification on the inner 
frame.
  if_vxlan now does a direct netisr dispatch to take full advantage of RSS. It 
is
  not very clear why it didn't do this already.
  
  Future work:
  Rx: it should be possible to avoid the first trip up the protocol stack to get
  the frame to if_vxlan just so it can decapsulate and requeue for a second trip
  up the stack. The hardware NIC driver could directly call an if_vxlan receive
  routine for VXLAN traffic instead.
  
  Rx: LRO. depends on what happens with the previous item. There will have to to
  be a mechanism to indicate that it's time for if_vxlan to flush its LRO state.
  
  Reviewed by:  kib@
  Relnotes: Yes
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D25873

Modified:
  head/share/man/man4/vxlan.4
  head/share/man/man9/EVENTHANDLER.9
  head/sys/net/if_vxlan.c
  head/sys/net/if_vxlan.h
  head/sys/netinet/ip_output.c
  head/sys/netinet6/ip6_output.c

Modified: head/share/man/man4/vxlan.4
==
--- head/share/man/man4/vxlan.4 Fri Sep 18 02:21:15 2020(r365869)
+++ head/share/man/man4/vxlan.4 Fri Sep 18 02:37:57 2020(r365870)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 31, 2017
+.Dd September 17, 2020
 .Dt VXLAN 4
 .Os
 .Sh NAME
@@ -182,6 +182,39 @@ command may be used to reduce the MTU size on the
 .Nm
 interface to allow the encapsulated frame to fit in the
 current MTU of the physical network.
+.Sh HARDWARE
+The
+.Nm
+driver supports hardware checksum offload (receive and transmit) and TSO on the
+encapsulated traffic over physical interfaces that support these features.
+The
+.Nm
+interface examines the
+.Cm vxlandev
+interface, if one is specified, or the interface hosting the
+.Cm vxlanlocal
+address, and configures its capabilities based on the hardware offload
+capabilities of that physical interface.
+If multiple physical interfaces will transmit or receive traffic for the
+.Nm
+then they all must have the same hardware capabilities.
+The transmit routine of a
+.Nm
+interface may fail with
+.Er ENXIO
+if an outbound physical interface does not support
+an offload that the
+.Nm
+interface is requesting.
+This can happen if there are multiple physical interfaces involved, with
+different hardware capabilities, or an interface capability was disabled after
+the
+.Nm
+interface had already started.
+.Pp
+At present, these devices are capable of generating checksums and performing 
TSO
+on the inner frames in hardware:
+.Xr cxgbe 4 .
 .Sh EXAMPLES
 Create a
 .Nm
@@ -244,3 +277,7 @@ The
 .Nm
 driver was written by
 .An Bryan Venteicher Aq bry...@freebsd.org .
+Support for stateless hardware offloads was added by
+.An Navdeep Parhar Aq n...@freebsd.org
+in
+.Fx 13.0 .

Modified: head/share/man/man9/EVENTHANDLER.9
==
--- head/share/man/man9/EVENTHANDLER.9  Fri Sep 18 02:21:15 2020
(r365869)
+++ head/share/man/man9/EVENTHANDLER.9  Fri Sep 18 02:37:57 2020
(r365870)
@@ -23,7 +23,7 @@
 .\" SUCH DAMAGE.
 .\" $FreeBSD$
 .\"
-.Dd October 21, 2018
+.Dd September 17, 2020
 .Dt EVENTHANDLER 9
 .Os
 .Sh NAME
@@ -389,6 +389,10 @@ Callback invoked when the vlan configuration has chang
 Callback invoked when a vlan is destroyed.
 .It Vt vm_lowmem
 Callbacks invoked when virtual memory is low.
+.It Vt vxlan_start
+Callback invoked when a vxlan interface starts.
+.It Vt vxlan_stop
+Callback invoked when a vxlan interface stops.
 .It Vt watchdog_list
 Callbacks invoked when the system watchdog timer is reinitialized.
 .El

Modified: head/sys/net/if_vxlan.c
==
--- head/sys/net/if_vxlan.c Fri Sep 18

svn commit: r365869 - in head/sys: netinet netinet6

2020-09-17 Thread Navdeep Parhar
Author: np
Date: Fri Sep 18 02:21:15 2020
New Revision: 365869
URL: https://svnweb.freebsd.org/changeset/base/365869

Log:
  Add a knob to allow zero UDP checksums for UDP/IPv6 traffic on the given UDP 
port.
  
  This will be used by some upcoming changes to if_vxlan(4).  RFC 7348 (VXLAN)
  says that the UDP checksum "SHOULD be transmitted as zero.  When a packet is
  received with a UDP checksum of zero, it MUST be accepted for decapsulation."
  But the original IPv6 RFCs did not allow zero UDP checksum.  RFC 6935 attempts
  to resolve this.
  
  Reviewed by:  kib@
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D25873

Modified:
  head/sys/netinet/udp_var.h
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/netinet/udp_var.h
==
--- head/sys/netinet/udp_var.h  Fri Sep 18 02:10:28 2020(r365868)
+++ head/sys/netinet/udp_var.h  Fri Sep 18 02:21:15 2020(r365869)
@@ -154,6 +154,9 @@ VNET_DECLARE(int, udp_log_in_vain);
 #defineV_udp_blackhole VNET(udp_blackhole)
 #defineV_udp_log_in_vain   VNET(udp_log_in_vain)
 
+VNET_DECLARE(int, zero_checksum_port);
+#defineV_zero_checksum_portVNET(zero_checksum_port)
+
 static __inline struct inpcbinfo *
 udp_get_inpcbinfo(int protocol)
 {

Modified: head/sys/netinet6/udp6_usrreq.c
==
--- head/sys/netinet6/udp6_usrreq.c Fri Sep 18 02:10:28 2020
(r365868)
+++ head/sys/netinet6/udp6_usrreq.c Fri Sep 18 02:21:15 2020
(r365869)
@@ -124,6 +124,11 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+VNET_DEFINE(int, zero_checksum_port) = 0;
+#defineV_zero_checksum_portVNET(zero_checksum_port)
+SYSCTL_INT(_net_inet6_udp6, OID_AUTO, rfc6935_port, CTLFLAG_VNET | CTLFLAG_RW,
+_NAME(zero_checksum_port), 0,
+"Zero UDP checksum allowed for traffic to/from this port.");
 /*
  * UDP protocol implementation.
  * Per RFC 768, August, 1980.
@@ -267,7 +272,14 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
}
if (uh->uh_sum == 0) {
UDPSTAT_INC(udps_nosum);
-   goto badunlocked;
+   /*
+* dport 0 was rejected earlier so this is OK even if
+* zero_checksum_port is 0 (which is its default value).
+*/
+   if (ntohs(uh->uh_dport) == V_zero_checksum_port)
+   goto skip_checksum;
+   else
+   goto badunlocked;
}
}
 
@@ -287,6 +299,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
goto badunlocked;
}
 
+skip_checksum:
/*
 * Construct sockaddr format source address.
 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365868 - in head: sbin/ifconfig sys/net

2020-09-17 Thread Navdeep Parhar
Author: np
Date: Fri Sep 18 02:10:28 2020
New Revision: 365868
URL: https://svnweb.freebsd.org/changeset/base/365868

Log:
  Add two new ifnet capabilities for hw checksumming and TSO for VXLAN traffic.
  
  These are similar to the existing VLAN capabilities.
  
  Reviewed by:  kib@
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D25873

Modified:
  head/sbin/ifconfig/ifconfig.8
  head/sbin/ifconfig/ifconfig.c
  head/sbin/ifconfig/ifvxlan.c
  head/sys/net/if.h

Modified: head/sbin/ifconfig/ifconfig.8
==
--- head/sbin/ifconfig/ifconfig.8   Fri Sep 18 01:38:47 2020
(r365867)
+++ head/sbin/ifconfig/ifconfig.8   Fri Sep 18 02:10:28 2020
(r365868)
@@ -28,7 +28,7 @@
 .\" From: @(#)ifconfig.8   8.3 (Berkeley) 1/5/94
 .\" $FreeBSD$
 .\"
-.Dd June 4, 2020
+.Dd September 17, 2020
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -587,7 +587,7 @@ If the driver offers user-configurable VLAN support, e
 reception of extended frames, tag processing in hardware,
 frame filtering in hardware, checksum offloading, or TSO on VLAN,
 respectively.
-Note that this must be issued on a physical interface associated with
+Note that this must be configured on a physical interface associated with
 .Xr vlan 4 ,
 not on a
 .Xr vlan 4
@@ -597,6 +597,21 @@ If the driver offers user-configurable VLAN support, d
 reception of extended frames, tag processing in hardware,
 frame filtering in hardware, or TSO on VLAN,
 respectively.
+.It Cm vxlanhwcsum , vxlanhwtso
+If the driver offers user-configurable VXLAN support, enable inner checksum
+offloading (receive and transmit) or TSO on VXLAN, respectively.
+Note that this must be configured on a physical interface associated with
+.Xr vxlan 4 ,
+not on a
+.Xr vxlan 4
+interface itself.
+The physical interface is either the interface specified as the vxlandev
+or the interface hosting the vxlanlocal address.
+The driver will offload as much checksum work and TSO as it can reliably
+support, the exact level of offloading may vary between drivers.
+.It Fl vxlanhwcsum , vxlanhwtso
+If the driver offers user-configurable VXLAN support, disable checksum
+offloading (receive and transmit) or TSO on VXLAN, respectively.
 .It Cm vnet Ar jail
 Move the interface to the
 .Xr jail 8 ,

Modified: head/sbin/ifconfig/ifconfig.c
==
--- head/sbin/ifconfig/ifconfig.c   Fri Sep 18 01:38:47 2020
(r365867)
+++ head/sbin/ifconfig/ifconfig.c   Fri Sep 18 02:10:28 2020
(r365868)
@@ -1344,7 +1344,8 @@ unsetifdescr(const char *val, int value, int s, const 
 "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
 "\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \
 "\17TOE4\20TOE6\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \
-"\26RXCSUM_IPV6\27TXCSUM_IPV6\31TXRTLMT\32HWRXTSTMP\33NOMAP\34TXTLS4\35TXTLS6"
+"\26RXCSUM_IPV6\27TXCSUM_IPV6\31TXRTLMT\32HWRXTSTMP\33NOMAP\34TXTLS4\35TXTLS6" 
\
+"\36VXLAN_HWCSUM\37VXLAN_HWTSO"
 
 /*
  * Print the status of the interface.  If an address family was

Modified: head/sbin/ifconfig/ifvxlan.c
==
--- head/sbin/ifconfig/ifvxlan.cFri Sep 18 01:38:47 2020
(r365867)
+++ head/sbin/ifconfig/ifvxlan.cFri Sep 18 02:10:28 2020
(r365868)
@@ -620,6 +620,11 @@ static struct cmd vxlan_cmds[] = {
 
DEF_CMD("vxlanflush", 0,setvxlan_flush),
DEF_CMD("vxlanflushall", 1, setvxlan_flush),
+
+   DEF_CMD("vxlanhwcsum",  IFCAP_VXLAN_HWCSUM, setifcap),
+   DEF_CMD("-vxlanhwcsum", -IFCAP_VXLAN_HWCSUM,setifcap),
+   DEF_CMD("vxlanhwtso",   IFCAP_VXLAN_HWTSO,  setifcap),
+   DEF_CMD("-vxlanhwtso",  -IFCAP_VXLAN_HWTSO, setifcap),
 };
 
 static struct afswtch af_vxlan = {

Modified: head/sys/net/if.h
==
--- head/sys/net/if.h   Fri Sep 18 01:38:47 2020(r365867)
+++ head/sys/net/if.h   Fri Sep 18 02:10:28 2020(r365868)
@@ -248,6 +248,8 @@ struct if_data {
 #defineIFCAP_NOMAP 0x400 /* can TX unmapped mbufs */
 #defineIFCAP_TXTLS40x800 /* can do TLS encryption and 
segmentation for TCP */
 #defineIFCAP_TXTLS60x1000 /* can do TLS encryption and 
segmentation for TCP6 */
+#defineIFCAP_VXLAN_HWCSUM  0x2000 /* can do IFCAN_HWCSUM on 
VXLANs */
+#defineIFCAP_VXLAN_HWTSO   0x4000 /* can do IFCAP_TSO on 
VXLANs */
 
 #define IFCAP_HWCSUM_IPV6  (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6)
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to 

svn commit: r365867 - head/sys/sys

2020-09-17 Thread Navdeep Parhar
Author: np
Date: Fri Sep 18 01:38:47 2020
New Revision: 365867
URL: https://svnweb.freebsd.org/changeset/base/365867

Log:
  mbuf checksum flags and fields to support tunneling protocols.
  
  These are being added to support VXLAN but will work for GENEVE as well.
  ENCAP_RSVD1 will likely become ENCAP_GENEVE in the future.
  
  The size of struct mbuf does not change and that means this change can be 
MFC'd.
  If size wasn't a constraint a cleaner way may have been to add 
inner_csum_flags
  and inner_csum_data to go with csum_flags and csum_data.
  
  Reviewed by:  kib@
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D25873

Modified:
  head/sys/sys/mbuf.h

Modified: head/sys/sys/mbuf.h
==
--- head/sys/sys/mbuf.h Fri Sep 18 01:11:11 2020(r365866)
+++ head/sys/sys/mbuf.h Fri Sep 18 01:38:47 2020(r365867)
@@ -171,7 +171,10 @@ struct pkthdr {
uint8_t  l3hlen;/* layer 3 hdr len */
uint8_t  l4hlen;/* layer 4 hdr len */
uint8_t  l5hlen;/* layer 5 hdr len */
-   uint32_t spare;
+   uint8_t  inner_l2hlen;
+   uint8_t  inner_l3hlen;
+   uint8_t  inner_l4hlen;
+   uint8_t  inner_l5hlen;
};
};
union {
@@ -616,7 +619,13 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgof
  * Outbound flags that are set by upper protocol layers requesting lower
  * layers, or ideally the hardware, to perform these offloading tasks.
  * For outbound packets this field and its flags can be directly tested
- * against ifnet if_hwassist.
+ * against ifnet if_hwassist.  Note that the outbound and the inbound flags do
+ * not collide right now but they could be allowed to (as long as the flags are
+ * scrubbed appropriately when the direction of an mbuf changes).  CSUM_BITS
+ * would also have to split into CSUM_BITS_TX and CSUM_BITS_RX.
+ *
+ * CSUM_INNER_ is the same as CSUM_ but it applies to the inner frame.
+ * The CSUM_ENCAP_ bits identify the outer encapsulation.
  */
 #defineCSUM_IP 0x0001  /* IP header checksum 
offload */
 #defineCSUM_IP_UDP 0x0002  /* UDP checksum offload 
*/
@@ -625,13 +634,28 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgof
 #defineCSUM_IP_TSO 0x0010  /* TCP segmentation 
offload */
 #defineCSUM_IP_ISCSI   0x0020  /* iSCSI checksum 
offload */
 
+#defineCSUM_INNER_IP6_UDP  0x0040
+#defineCSUM_INNER_IP6_TCP  0x0080
+#defineCSUM_INNER_IP6_TSO  0x0100
 #defineCSUM_IP6_UDP0x0200  /* UDP checksum offload 
*/
 #defineCSUM_IP6_TCP0x0400  /* TCP checksum offload 
*/
 #defineCSUM_IP6_SCTP   0x0800  /* SCTP checksum 
offload */
 #defineCSUM_IP6_TSO0x1000  /* TCP segmentation 
offload */
 #defineCSUM_IP6_ISCSI  0x2000  /* iSCSI checksum 
offload */
 
+#defineCSUM_INNER_IP   0x4000
+#defineCSUM_INNER_IP_UDP   0x8000
+#defineCSUM_INNER_IP_TCP   0x0001
+#defineCSUM_INNER_IP_TSO   0x0002
+
+#defineCSUM_ENCAP_VXLAN0x0004  /* VXLAN outer 
encapsulation */
+#defineCSUM_ENCAP_RSVD10x0008
+
 /* Inbound checksum support where the checksum was verified by hardware. */
+#defineCSUM_INNER_L3_CALC  0x0010
+#defineCSUM_INNER_L3_VALID 0x0020
+#defineCSUM_INNER_L4_CALC  0x0040
+#defineCSUM_INNER_L4_VALID 0x0080
 #defineCSUM_L3_CALC0x0100  /* calculated layer 3 
csum */
 #defineCSUM_L3_VALID   0x0200  /* checksum is correct 
*/
 #defineCSUM_L4_CALC0x0400  /* calculated layer 4 
csum */
@@ -642,16 +666,31 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgof
 
 #defineCSUM_SND_TAG0x8000  /* Packet header has 
send tag */
 
+#define CSUM_FLAGS_TX (CSUM_IP | CSUM_IP_UDP | CSUM_IP_TCP | CSUM_IP_SCTP | \
+CSUM_IP_TSO | CSUM_IP_ISCSI | CSUM_INNER_IP6_UDP | CSUM_INNER_IP6_TCP | \
+CSUM_INNER_IP6_TSO | CSUM_IP6_UDP | CSUM_IP6_TCP | CSUM_IP6_SCTP | \
+CSUM_IP6_TSO | CSUM_IP6_ISCSI | CSUM_INNER_IP | CSUM_INNER_IP_UDP | \
+CSUM_INNER_IP_TCP | CSUM_INNER_IP_TSO | CSUM_ENCAP_VXLAN | \
+CSUM_ENCAP_RSVD1 | CSUM_SND_TAG)
+
+#define CSUM_FLAGS_RX (CSUM_INNER_L3_CALC | CSUM_INNER_L3_VALID | \
+CSUM_INNER_L4_CALC | CSUM_INNER_L4_VALID | CSUM_L3_CALC | CSUM_L3_VALID | \
+CSUM_L4_CALC | CSUM_L4_VALID | CSUM_L5_CALC | 

svn commit: r365861 - in head/sys: conf dev/cxgbe/firmware modules/cxgbe/t4_firmware modules/cxgbe/t5_firmware modules/cxgbe/t6_firmware

2020-09-17 Thread Navdeep Parhar
Author: np
Date: Thu Sep 17 22:14:11 2020
New Revision: 365861
URL: https://svnweb.freebsd.org/changeset/base/365861

Log:
  cxgbe(4): Update T4/5/6 firmwares to 1.25.0.0.
  
  Obtained from:Chelsio Communications
  MFC after:3 days
  Sponsored by: Chelsio Communications

Added:
  head/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin   (contents, props changed)
  head/sys/dev/cxgbe/firmware/t5fw-1.25.0.0.bin   (contents, props changed)
  head/sys/dev/cxgbe/firmware/t6fw-1.25.0.0.bin   (contents, props changed)
Deleted:
  head/sys/dev/cxgbe/firmware/t4fw-1.24.12.0.bin
  head/sys/dev/cxgbe/firmware/t5fw-1.24.12.0.bin
  head/sys/dev/cxgbe/firmware/t6fw-1.24.12.0.bin
Modified:
  head/sys/conf/files
  head/sys/dev/cxgbe/firmware/t4fw_interface.h
  head/sys/dev/cxgbe/firmware/t6fw_cfg.txt
  head/sys/dev/cxgbe/firmware/t6fw_cfg_uwire.txt
  head/sys/modules/cxgbe/t4_firmware/Makefile
  head/sys/modules/cxgbe/t5_firmware/Makefile
  head/sys/modules/cxgbe/t6_firmware/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Thu Sep 17 21:51:05 2020(r365860)
+++ head/sys/conf/files Thu Sep 17 22:14:11 2020(r365861)
@@ -1514,7 +1514,7 @@ t4fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t4fw.fwo"
 t4fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t4fw-1.24.12.0.bin"  \
+   dependency  "$S/dev/cxgbe/firmware/t4fw-1.25.0.0.bin"   \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t4fw.fw"
@@ -1548,7 +1548,7 @@ t5fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t5fw.fwo"
 t5fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t5fw-1.24.12.0.bin"  \
+   dependency  "$S/dev/cxgbe/firmware/t5fw-1.25.0.0.bin"   \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t5fw.fw"
@@ -1582,7 +1582,7 @@ t6fw.fwo  optional cxgbe  
\
no-implicit-rule\
clean   "t6fw.fwo"
 t6fw.fwoptional cxgbe  
\
-   dependency  "$S/dev/cxgbe/firmware/t6fw-1.24.12.0.bin"  \
+   dependency  "$S/dev/cxgbe/firmware/t6fw-1.25.0.0.bin"   \
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t6fw.fw"

Added: head/sys/dev/cxgbe/firmware/t4fw-1.25.0.0.bin
==

Modified: head/sys/dev/cxgbe/firmware/t4fw_interface.h
==
--- head/sys/dev/cxgbe/firmware/t4fw_interface.hThu Sep 17 21:51:05 
2020(r365860)
+++ head/sys/dev/cxgbe/firmware/t4fw_interface.hThu Sep 17 22:14:11 
2020(r365861)
@@ -4690,6 +4690,7 @@ enum fw_caps_config_crypto {
FW_CAPS_CONFIG_CRYPTO_LOOKASIDE = 0x0001,
FW_CAPS_CONFIG_TLSKEYS = 0x0002,
FW_CAPS_CONFIG_IPSEC_INLINE = 0x0004,
+   FW_CAPS_CONFIG_TLS_HW = 0x0008,
 };
 
 enum fw_caps_config_fcoe {
@@ -4838,6 +4839,7 @@ enum fw_params_param_dev {
FW_PARAMS_PARAM_DEV_TCB_CACHE_FLUSH = 0x2D,
FW_PARAMS_PARAM_DEV_FILTER = 0x2E,
FW_PARAMS_PARAM_DEV_CLIP2_CMD = 0x2F,
+   FW_PARAMS_PARAM_DEV_KTLS_HW = 0x31,
 };
 
 /*
@@ -4874,6 +4876,13 @@ enum fw_params_param_dev_filter{
FW_PARAM_DEV_FILTER_MODE_MASK   = 0x01,
 };
 
+enum fw_params_param_dev_ktls_hw {
+   FW_PARAMS_PARAM_DEV_KTLS_HW_DISABLE = 0x00,
+   FW_PARAMS_PARAM_DEV_KTLS_HW_ENABLE  = 0x01,
+   FW_PARAMS_PARAM_DEV_KTLS_HW_USER_DISABLE = 0x00,
+   FW_PARAMS_PARAM_DEV_KTLS_HW_USER_ENABLE  = 0x01,
+};
+
 enum fw_params_param_dev_fwcache {
FW_PARAM_DEV_FWCACHE_FLUSH  = 0x00,
FW_PARAM_DEV_FWCACHE_FLUSHINV   = 0x01,
@@ -9638,6 +9647,7 @@ struct fw_debug_cmd {
 
 enum fw_diag_cmd_type {
FW_DIAG_CMD_TYPE_OFLDIAG = 0,
+   FW_DIAG_CMD_TYPE_MEM_TEST_DIAG,
 };
 
 enum fw_diag_cmd_ofldiag_op {
@@ -9654,6 +9664,22 @@ enum fw_diag_cmd_ofldiag_status {
FW_DIAG_CMD_OFLDIAG_STATUS_PASSED,
 };
 
+enum fw_diag_cmd_memdiag_op {
+   FW_DIAG_CMD_MEMDIAG_TEST_START=1,
+   FW_DIAG_CMD_MEMDIAG_TEST_STOP,
+   

svn commit: r365732 - head/sys/dev/cxgbe/common

2020-09-14 Thread Navdeep Parhar
Author: np
Date: Mon Sep 14 22:15:54 2020
New Revision: 365732
URL: https://svnweb.freebsd.org/changeset/base/365732

Log:
  cxgbe(4): Get the count of FCS errors from the MAC and not MPS for T6 ports.
  
  The MPS register on the T6 counts something other than FCS errors despite its
  name.
  
  MFC after:3 days
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/common/t4_hw.c

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Mon Sep 14 21:33:11 2020
(r365731)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Mon Sep 14 22:15:54 2020
(r365732)
@@ -6853,6 +6853,7 @@ void t4_get_port_stats_offset(struct adapter *adap, in
 void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
 {
u32 bgmap = adap2pinfo(adap, idx)->mps_bg_map;
+   struct link_config *lc = >port[idx]->link_cfg;
u32 stat_ctl = t4_read_reg(adap, A_MPS_STAT_CTL);
 
 #define GET_STAT(name) \
@@ -6902,7 +6903,6 @@ void t4_get_port_stats(struct adapter *adap, int idx, 
p->rx_ucast_frames  = GET_STAT(RX_PORT_UCAST);
p->rx_too_long  = GET_STAT(RX_PORT_MTU_ERROR);
p->rx_jabber= GET_STAT(RX_PORT_MTU_CRC_ERROR);
-   p->rx_fcs_err   = GET_STAT(RX_PORT_CRC_ERROR);
p->rx_len_err   = GET_STAT(RX_PORT_LEN_ERROR);
p->rx_symbol_err= GET_STAT(RX_PORT_SYM_ERROR);
p->rx_runt  = GET_STAT(RX_PORT_LESS_64B);
@@ -6922,6 +6922,26 @@ void t4_get_port_stats(struct adapter *adap, int idx, 
p->rx_ppp6  = GET_STAT(RX_PORT_PPP6);
p->rx_ppp7  = GET_STAT(RX_PORT_PPP7);
 
+   /*
+* The T6's MPS's RX_PORT_CRC_ERROR register doesn't actually count CRC
+* errors so get that information from the MAC instead.  Which MAC is in
+* use depends on speed and FEC.  The MAC counters clear on reset or
+* link state change so we are only reporting errors for this
+* incarnation of the link here.
+*/
+   if (chip_id(adap) != CHELSIO_T6)
+   p->rx_fcs_err = GET_STAT(RX_PORT_CRC_ERROR);
+   else if (lc->link_ok) {
+   if (lc->speed > 25000 ||
+   (lc->speed == 25000 && lc->fec == FEC_RS)) {
+   p->rx_fcs_err = t4_read_reg64(adap, T5_PORT_REG(idx,
+   A_MAC_PORT_AFRAMECHECKSEQUENCEERRORS));
+   } else {
+   p->rx_fcs_err = t4_read_reg64(adap, T5_PORT_REG(idx,
+   A_MAC_PORT_MTIP_1G10G_RX_CRCERRORS));
+   }
+   }
+
if (chip_id(adap) >= CHELSIO_T5) {
if (stat_ctl & F_COUNTPAUSESTATRX) {
p->rx_frames -= p->rx_pause;
@@ -10757,6 +10777,12 @@ void t4_clr_port_stats(struct adapter *adap, int idx)
t4_write_reg(adap,
A_MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_L + i * 8, 0);
}
+   if (chip_id(adap) == CHELSIO_T6) {
+   t4_write_reg64(adap, T5_PORT_REG(idx,
+   A_MAC_PORT_AFRAMECHECKSEQUENCEERRORS), 0);
+   t4_write_reg64(adap, T5_PORT_REG(idx,
+   A_MAC_PORT_MTIP_1G10G_RX_CRCERRORS), 0);
+   }
 }
 
 /**
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365014 - head/sys/dev/cxgbe

2020-08-31 Thread Navdeep Parhar
Author: np
Date: Mon Aug 31 22:44:59 2020
New Revision: 365014
URL: https://svnweb.freebsd.org/changeset/base/365014

Log:
  cxgbe(4): Check for descriptors before writing a TLS or raw work request.
  
  This fixes a regression in r362905.
  
  Submitted by: jhb@
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Mon Aug 31 21:57:01 2020(r365013)
+++ head/sys/dev/cxgbe/t4_sge.c Mon Aug 31 22:44:59 2020(r365014)
@@ -3004,6 +3004,14 @@ eth_tx(struct mp_ring *r, u_int cidx, u_int pidx, bool
 
MPASS(rc != 0 && rc != EAGAIN);
MPASS(txp->npkt == 0);
+
+   n = tx_len16_to_desc(mbuf_len16(m0));
+   if (__predict_false(avail < n)) {
+   avail += reclaim_tx_descs(txq, min(n, 32));
+   if (avail < n)
+   break;  /* out of descriptors */
+   }
+
wr = >desc[eq->pidx];
if (mbuf_cflags(m0) & MC_RAW_WR) {
n = write_raw_wr(txq, wr, m0, avail);
@@ -3014,12 +3022,6 @@ eth_tx(struct mp_ring *r, u_int cidx, u_int pidx, bool
avail);
 #endif
} else {
-   n = tx_len16_to_desc(mbuf_len16(m0));
-   if (__predict_false(avail < n)) {
-   avail += reclaim_tx_descs(txq, 32);
-   if (avail < n)
-   break;  /* out of descriptors */
-   }
ETHER_BPF_MTAP(ifp, m0);
if (sc->flags & IS_VF)
n = write_txpkt_vm_wr(sc, txq, m0);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364849 - stable/12/sys/dev/cxgbe

2020-08-26 Thread Navdeep Parhar
Author: np
Date: Wed Aug 26 23:41:46 2020
New Revision: 364849
URL: https://svnweb.freebsd.org/changeset/base/364849

Log:
  MFC r358924:
  
  cxgbe(4): Do not display error messages related to the CLIP table if
  it's not in use by TOE or KTLS.

Modified:
  stable/12/sys/dev/cxgbe/t4_clip.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/t4_clip.c
==
--- stable/12/sys/dev/cxgbe/t4_clip.c   Wed Aug 26 23:21:26 2020
(r364848)
+++ stable/12/sys/dev/cxgbe/t4_clip.c   Wed Aug 26 23:41:46 2020
(r364849)
@@ -273,8 +273,11 @@ update_clip_table(struct adapter *sc)
 
inet_ntop(AF_INET6, >lip, [0],
sizeof(ip));
-   log(LOG_ERR, "%s: could not add %s (%d)\n",
-   __func__, ip, rc);
+   if (sc->active_ulds != 0) {
+   log(LOG_ERR,
+   "%s: could not add %s (%d)\n",
+   __func__, ip, rc);
+   }
free(ce, M_CXGBE);
}
 next:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364848 - in stable/12/sys/dev/cxgbe: . common

2020-08-26 Thread Navdeep Parhar
Author: np
Date: Wed Aug 26 23:21:26 2020
New Revision: 364848
URL: https://svnweb.freebsd.org/changeset/base/364848

Log:
  MFC r340023 (by jhb@), r362905, r362938, and r363167.
  
  r340023:
  Check cannot_use_txpkts() rather than needs_tso() in add_to_txpkts().
  
  Currently this is a no-op, but will matter in the future when
  cannot_use_txpkts() starts checking other conditions than just
  needs_tso().
  
  r362905:
  cxgbe(4): changes in the Tx path to help increase tx coalescing.
  
  - Ask the firmware for the number of frames that can be stuffed in one
work request.
  
  - Modify mp_ring to increase the likelihood of tx coalescing when there
are just one or two threads that are doing most of the tx.  Add teeth
to the abdication mechanism by pushing the consumer lock into mp_ring.
This reduces the likelihood that a consumer will get stuck with all
the work even though it is above its budget.
  
  - Add support for coalesced tx WR to the VF driver.  This, with the
changes above, results in a 7x improvement in the tx pps of the VF
driver for some common cases.  The firmware vets the L2 headers
submitted by the VF driver and it's a big win if the checks are
performed for a batch of packets and not each one individually.
  
  r362938:
  cxgbe(4): Fix a bug (introduced in r362905) where some tx traffic wasn't
  being reported to BPF.
  
  r363167:
  cxgbev(4): Compare at most 16 bytes of the Ethernet header when trying
  to coalesce tx work requests.
  
  Note that Coverity will still treat this as an out-of-bounds access.  We
  do want to compare 16B starting from ethmacdst but cmp_l2hdr was was
  going beyond that by 2B.
  
  cmp_l2hdr was introduced in r362905.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/common/common.h
  stable/12/sys/dev/cxgbe/t4_main.c
  stable/12/sys/dev/cxgbe/t4_mp_ring.c
  stable/12/sys/dev/cxgbe/t4_mp_ring.h
  stable/12/sys/dev/cxgbe/t4_sge.c
  stable/12/sys/dev/cxgbe/t4_vf.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Wed Aug 26 22:52:07 2020
(r364847)
+++ stable/12/sys/dev/cxgbe/adapter.h   Wed Aug 26 23:21:26 2020
(r364848)
@@ -546,6 +546,23 @@ struct sge_fl {
 
 struct mp_ring;
 
+struct txpkts {
+   uint8_t wr_type;/* type 0 or type 1 */
+   uint8_t npkt;   /* # of packets in this work request */
+   uint8_t len16;  /* # of 16B pieces used by this work request */
+   uint8_t score;  /* 1-10. coalescing attempted if score > 3 */
+   uint8_t max_npkt;   /* maximum number of packets allowed */
+   uint16_t plen;  /* total payload (sum of all packets) */
+
+   /* straight from fw_eth_tx_pkts_vm_wr. */
+   __u8   ethmacdst[6];
+   __u8   ethmacsrc[6];
+   __be16 ethtype;
+   __be16 vlantci;
+
+   struct mbuf *mb[15];
+};
+
 /* txq: SGE egress queue + what's needed for Ethernet NIC */
 struct sge_txq {
struct sge_eq eq;   /* MUST be first */
@@ -556,6 +573,7 @@ struct sge_txq {
struct sglist *gl;
__be32 cpl_ctrl0;   /* for convenience */
int tc_idx; /* traffic class */
+   struct txpkts txp;
 
struct task tx_reclaim_task;
/* stats for common events first */

Modified: stable/12/sys/dev/cxgbe/common/common.h
==
--- stable/12/sys/dev/cxgbe/common/common.h Wed Aug 26 22:52:07 2020
(r364847)
+++ stable/12/sys/dev/cxgbe/common/common.h Wed Aug 26 23:21:26 2020
(r364848)
@@ -393,6 +393,7 @@ struct adapter_params {
bool ulptx_memwrite_dsgl;   /* use of T5 DSGL allowed */
bool fr_nsmr_tpte_wr_support;   /* FW support for FR_NSMR_TPTE_WR */
bool viid_smt_extn_support; /* FW returns vin, vfvld & smt index? */
+   unsigned int max_pkts_per_eth_tx_pkts_wr;
 };
 
 #define CHELSIO_T4 0x4

Modified: stable/12/sys/dev/cxgbe/t4_main.c
==
--- stable/12/sys/dev/cxgbe/t4_main.c   Wed Aug 26 22:52:07 2020
(r364847)
+++ stable/12/sys/dev/cxgbe/t4_main.c   Wed Aug 26 23:21:26 2020
(r364848)
@@ -2107,7 +2107,7 @@ cxgbe_transmit(struct ifnet *ifp, struct mbuf *m)
vi->rsrv_noflowq);
 
items[0] = m;
-   rc = mp_ring_enqueue(txq->r, items, 1, 4096);
+   rc = mp_ring_enqueue(txq->r, items, 1, 256);
if (__predict_false(rc != 0))
m_freem(m);
 
@@ -2128,7 +2128,7 @@ cxgbe_qflush(struct ifnet *ifp)
txq->eq.flags |= EQ_QFLUSH;
TXQ_UNLOCK(txq);
while (!mp_ring_is_idle(txq->r)) {
-   

svn commit: r364776 - in stable/12/sys/dev/cxgbe: common cudbg

2020-08-25 Thread Navdeep Parhar
Author: np
Date: Tue Aug 25 18:21:13 2020
New Revision: 364776
URL: https://svnweb.freebsd.org/changeset/base/364776

Log:
  MFC r363498:
  cxgbe(4): Some updates to the common code.

Modified:
  stable/12/sys/dev/cxgbe/common/common.h
  stable/12/sys/dev/cxgbe/common/t4_hw.c
  stable/12/sys/dev/cxgbe/common/t4_hw.h
  stable/12/sys/dev/cxgbe/cudbg/cudbg_lib.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/common/common.h
==
--- stable/12/sys/dev/cxgbe/common/common.h Tue Aug 25 18:16:40 2020
(r364775)
+++ stable/12/sys/dev/cxgbe/common/common.h Tue Aug 25 18:21:13 2020
(r364776)
@@ -301,6 +301,7 @@ struct chip_params {
u16 vfcount;
u32 sge_fl_db;
u16 mps_tcam_size;
+   u16 rss_nentries;
 };
 
 /* VF-only parameters. */
@@ -379,6 +380,7 @@ struct adapter_params {
unsigned int hash_filter:1;
unsigned int filter2_wr_support:1;
unsigned int port_caps32:1;
+   unsigned int smac_add_support:1;
 
unsigned int ofldq_wr_cred;
unsigned int eo_wr_cred;
@@ -784,8 +786,27 @@ int t4_set_rxmode(struct adapter *adap, unsigned int m
 int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox, unsigned int 
viid,
  bool free, unsigned int naddr, const u8 **addr, u16 *idx,
  u64 *hash, bool sleep_ok);
+int t4_free_mac_filt(struct adapter *adap, unsigned int mbox,
+ unsigned int viid, unsigned int naddr,
+ const u8 **addr, bool sleep_ok);
+int t4_free_encap_mac_filt(struct adapter *adap, unsigned int viid,
+  int idx, bool sleep_ok);
+int t4_free_raw_mac_filt(struct adapter *adap, unsigned int viid,
+const u8 *addr, const u8 *mask, unsigned int idx,
+u8 lookup_type, u8 port_id, bool sleep_ok);
+int t4_alloc_raw_mac_filt(struct adapter *adap, unsigned int viid,
+ const u8 *addr, const u8 *mask, unsigned int idx,
+ u8 lookup_type, u8 port_id, bool sleep_ok);
+int t4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid,
+   const u8 *addr, const u8 *mask, unsigned int vni,
+   unsigned int vni_mask, u8 dip_hit, u8 lookup_type,
+   bool sleep_ok);
 int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
  int idx, const u8 *addr, bool persist, uint16_t *smt_idx);
+int t4_del_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
+  const u8 *addr, bool smac);
+int t4_add_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
+  int idx, const u8 *addr, bool persist, u8 *smt_idx, bool smac);
 int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int 
viid,
 bool ucast, u64 vec, bool sleep_ok);
 int t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
@@ -798,6 +819,10 @@ int t4_mdio_rd(struct adapter *adap, unsigned int mbox
   unsigned int mmd, unsigned int reg, unsigned int *valp);
 int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
   unsigned int mmd, unsigned int reg, unsigned int val);
+int t4_i2c_io(struct adapter *adap, unsigned int mbox,
+ int port, unsigned int devid,
+ unsigned int offset, unsigned int len,
+ u8 *buf, bool write);
 int t4_i2c_rd(struct adapter *adap, unsigned int mbox,
  int port, unsigned int devid,
  unsigned int offset, unsigned int len,
@@ -822,7 +847,7 @@ int t4_sge_ctxt_rd(struct adapter *adap, unsigned int 
   enum ctxt_type ctype, u32 *data);
 int t4_sge_ctxt_rd_bd(struct adapter *adap, unsigned int cid, enum ctxt_type 
ctype,
  u32 *data);
-int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox);
+int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox, int ctxt_type);
 const char *t4_link_down_rc_str(unsigned char link_down_rc);
 int t4_update_port_info(struct port_info *pi);
 int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
@@ -855,6 +880,10 @@ void t4_tp_tm_pio_read(struct adapter *adap, u32 *buff
   u32 start_index, bool sleep_ok);
 void t4_tp_mib_read(struct adapter *adap, u32 *buff, u32 nregs,
u32 start_index, bool sleep_ok);
+int t4_configure_ringbb(struct adapter *adap);
+int t4_configure_add_smac(struct adapter *adap);
+int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
+   u16 vlan);
 
 static inline int t4vf_query_params(struct adapter *adapter,
unsigned int nparams, const u32 *params,

Modified: stable/12/sys/dev/cxgbe/common/t4_hw.c

svn commit: r364774 - stable/12/sys/dev/cxgbe/cxgbei

2020-08-25 Thread Navdeep Parhar
Author: np
Date: Tue Aug 25 18:11:45 2020
New Revision: 364774
URL: https://svnweb.freebsd.org/changeset/base/364774

Log:
  MFC r36:
  cxgbei: destroy the worker threads' CV and mutex in stop_worker_threads.

Modified:
  stable/12/sys/dev/cxgbe/cxgbei/cxgbei.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/cxgbei/cxgbei.c
==
--- stable/12/sys/dev/cxgbe/cxgbei/cxgbei.c Tue Aug 25 17:23:33 2020
(r364773)
+++ stable/12/sys/dev/cxgbe/cxgbei/cxgbei.c Tue Aug 25 18:11:45 2020
(r364774)
@@ -714,6 +714,8 @@ stop_worker_threads(void)
cv_wait(>cwt_cv, >cwt_lock);
} while (cwt->cwt_state != CWT_STOPPED);
mtx_unlock(>cwt_lock);
+   mtx_destroy(>cwt_lock);
+   cv_destroy(>cwt_cv);
}
free(cwt_softc, M_CXGBE);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364750 - in stable/12/sys/dev/cxgbe: . cxgbei tom

2020-08-24 Thread Navdeep Parhar
Author: np
Date: Tue Aug 25 02:54:48 2020
New Revision: 364750
URL: https://svnweb.freebsd.org/changeset/base/364750

Log:
  MFC r362616:
  
  cxgbe(4): Add a pointer to the adapter softc in vi_info.
  
  There were quite a few places where port_info was being accessed only to
  get to the adapter.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
  stable/12/sys/dev/cxgbe/t4_main.c
  stable/12/sys/dev/cxgbe/t4_netmap.c
  stable/12/sys/dev/cxgbe/t4_sge.c
  stable/12/sys/dev/cxgbe/t4_vf.c
  stable/12/sys/dev/cxgbe/tom/t4_listen.c
  stable/12/sys/dev/cxgbe/tom/t4_tom.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Tue Aug 25 02:42:48 2020
(r364749)
+++ stable/12/sys/dev/cxgbe/adapter.h   Tue Aug 25 02:54:48 2020
(r364750)
@@ -187,6 +187,7 @@ enum {
 struct vi_info {
device_t dev;
struct port_info *pi;
+   struct adapter *adapter;
 
struct ifnet *ifp;
 
@@ -931,22 +932,22 @@ struct adapter {
 #define TXQ_LOCK_ASSERT_NOTOWNED(txq)  EQ_LOCK_ASSERT_NOTOWNED(&(txq)->eq)
 
 #define for_each_txq(vi, iter, q) \
-   for (q = >pi->adapter->sge.txq[vi->first_txq], iter = 0; \
+   for (q = >adapter->sge.txq[vi->first_txq], iter = 0; \
iter < vi->ntxq; ++iter, ++q)
 #define for_each_rxq(vi, iter, q) \
-   for (q = >pi->adapter->sge.rxq[vi->first_rxq], iter = 0; \
+   for (q = >adapter->sge.rxq[vi->first_rxq], iter = 0; \
iter < vi->nrxq; ++iter, ++q)
 #define for_each_ofld_txq(vi, iter, q) \
-   for (q = >pi->adapter->sge.ofld_txq[vi->first_ofld_txq], iter = 0; \
+   for (q = >adapter->sge.ofld_txq[vi->first_ofld_txq], iter = 0; \
iter < vi->nofldtxq; ++iter, ++q)
 #define for_each_ofld_rxq(vi, iter, q) \
-   for (q = >pi->adapter->sge.ofld_rxq[vi->first_ofld_rxq], iter = 0; \
+   for (q = >adapter->sge.ofld_rxq[vi->first_ofld_rxq], iter = 0; \
iter < vi->nofldrxq; ++iter, ++q)
 #define for_each_nm_txq(vi, iter, q) \
-   for (q = >pi->adapter->sge.nm_txq[vi->first_nm_txq], iter = 0; \
+   for (q = >adapter->sge.nm_txq[vi->first_nm_txq], iter = 0; \
iter < vi->nnmtxq; ++iter, ++q)
 #define for_each_nm_rxq(vi, iter, q) \
-   for (q = >pi->adapter->sge.nm_rxq[vi->first_nm_rxq], iter = 0; \
+   for (q = >adapter->sge.nm_rxq[vi->first_nm_rxq], iter = 0; \
iter < vi->nnmrxq; ++iter, ++q)
 #define for_each_vi(_pi, _iter, _vi) \
for ((_vi) = (_pi)->vi, (_iter) = 0; (_iter) < (_pi)->nvi; \

Modified: stable/12/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
==
--- stable/12/sys/dev/cxgbe/cxgbei/icl_cxgbei.c Tue Aug 25 02:42:48 2020
(r364749)
+++ stable/12/sys/dev/cxgbe/cxgbei/icl_cxgbei.c Tue Aug 25 02:54:48 2020
(r364750)
@@ -671,7 +671,7 @@ icl_cxgbei_conn_handoff(struct icl_conn *ic, int fd)
MPASS(tp->tod != NULL);
MPASS(tp->t_toe != NULL);
toep = tp->t_toe;
-   MPASS(toep->vi->pi->adapter == icc->sc);
+   MPASS(toep->vi->adapter == icc->sc);
icc->toep = toep;
icc->cwt = cxgbei_select_worker_thread(icc);
 

Modified: stable/12/sys/dev/cxgbe/t4_main.c
==
--- stable/12/sys/dev/cxgbe/t4_main.c   Tue Aug 25 02:42:48 2020
(r364749)
+++ stable/12/sys/dev/cxgbe/t4_main.c   Tue Aug 25 02:54:48 2020
(r364750)
@@ -1297,6 +1297,7 @@ t4_attach(device_t dev)
pi->nvi = num_vis;
for_each_vi(pi, j, vi) {
vi->pi = pi;
+   vi->adapter = sc;
vi->qsize_rxq = t4_qsize_rxq;
vi->qsize_txq = t4_qsize_txq;
 
@@ -1695,7 +1696,7 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
ifp->if_capabilities |= IFCAP_TOE;
 #endif
 #ifdef RATELIMIT
-   if (is_ethoffload(vi->pi->adapter) && vi->nofldtxq != 0) {
+   if (is_ethoffload(vi->adapter) && vi->nofldtxq != 0) {
ifp->if_capabilities |= IFCAP_TXRTLMT;
ifp->if_capenable |= IFCAP_TXRTLMT;
}
@@ -1706,7 +1707,7 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
ifp->if_hw_tsomax = IP_MAXPACKET;
ifp->if_hw_tsomaxsegcount = TX_SGL_SEGS_TSO;
 #ifdef RATELIMIT
-   if (is_ethoffload(vi->pi->adapter) && vi->nofldtxq != 0)
+   if (is_ethoffload(vi->adapter) && vi->nofldtxq != 0)
ifp->if_hw_tsomaxsegcount = TX_SGL_SEGS_EO_TSO;
 #endif
ifp->if_hw_tsomaxsegsize = 65536;
@@ -1834,7 +1835,7 @@ static void
 cxgbe_init(void *arg)
 {
struct vi_info *vi = arg;
-   struct adapter *sc = 

svn commit: r364748 - stable/12/sys/dev/cxgbe

2020-08-24 Thread Navdeep Parhar
Author: np
Date: Tue Aug 25 02:42:07 2020
New Revision: 364748
URL: https://svnweb.freebsd.org/changeset/base/364748

Log:
  MFC r362532:
  
  cxgbe(4): Add a tx_len16_to_desc helper.
  
  No functional change.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/t4_sge.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Tue Aug 25 02:22:49 2020
(r364747)
+++ stable/12/sys/dev/cxgbe/adapter.h   Tue Aug 25 02:42:07 2020
(r364748)
@@ -1313,4 +1313,12 @@ write_via_memwin(struct adapter *sc, int idx, uint32_t
 
return (rw_via_memwin(sc, idx, addr, (void *)(uintptr_t)val, len, 1));
 }
+
+/* Number of len16 -> number of descriptors */
+static inline int
+tx_len16_to_desc(int len16)
+{
+
+   return (howmany(len16, EQ_ESIZE / 16));
+}
 #endif

Modified: stable/12/sys/dev/cxgbe/t4_sge.c
==
--- stable/12/sys/dev/cxgbe/t4_sge.cTue Aug 25 02:22:49 2020
(r364747)
+++ stable/12/sys/dev/cxgbe/t4_sge.cTue Aug 25 02:42:07 2020
(r364748)
@@ -2522,7 +2522,7 @@ start_wrq_wr(struct sge_wrq *wrq, int len16, struct wr
void *w;
 
MPASS(len16 > 0);
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc > 0 && ndesc <= SGE_MAX_WR_NDESC);
 
EQ_LOCK(eq);
@@ -2734,9 +2734,9 @@ eth_tx(struct mp_ring *r, u_int cidx, u_int pidx)
M_ASSERTPKTHDR(m0);
MPASS(m0->m_nextpkt == NULL);
 
-   if (available < SGE_MAX_WR_NDESC) {
+   if (available < tx_len16_to_desc(mbuf_len16(m0))) {
available += reclaim_tx_descs(txq, 64);
-   if (available < howmany(mbuf_len16(m0), EQ_ESIZE / 16))
+   if (available < tx_len16_to_desc(mbuf_len16(m0)))
break;  /* out of descriptors */
}
 
@@ -4440,7 +4440,7 @@ write_txpkt_vm_wr(struct adapter *sc, struct sge_txq *
ctrl = sizeof(struct cpl_tx_pkt_core);
if (needs_tso(m0))
ctrl += sizeof(struct cpl_tx_pkt_lso_core);
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
 
/* Firmware work request header */
@@ -4551,7 +4551,7 @@ write_raw_wr(struct sge_txq *txq, void *wr, struct mbu
int len16, ndesc;
 
len16 = mbuf_len16(m0);
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
 
dst = wr;
@@ -4603,7 +4603,7 @@ write_txpkt_wr(struct adapter *sc, struct sge_txq *txq
sizeof(struct cpl_tx_pkt_core) + pktlen, 16);
nsegs = 0;
}
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
 
/* Firmware work request header */
@@ -4709,7 +4709,7 @@ try_txpkts(struct mbuf *m, struct mbuf *n, struct txpk
l2 = txpkts0_len16(nsegs2);
}
txp->len16 = howmany(sizeof(struct fw_eth_tx_pkts_wr), 16) + l1 + l2;
-   needed = howmany(txp->len16, EQ_ESIZE / 16);
+   needed = tx_len16_to_desc(txp->len16);
if (needed > SGE_MAX_WR_NDESC || needed > available)
return (1);
 
@@ -4743,7 +4743,7 @@ add_to_txpkts(struct mbuf *m, struct txpkts *txp, u_in
len16 = txpkts0_len16(nsegs);
else
len16 = txpkts1_len16();
-   needed = howmany(txp->len16 + len16, EQ_ESIZE / 16);
+   needed = tx_len16_to_desc(txp->len16 + len16);
if (needed > SGE_MAX_WR_NDESC || needed > available)
return (1);
 
@@ -4784,7 +4784,7 @@ write_txpkts_wr(struct adapter *sc, struct sge_txq *tx
MPASS(txp->len16 <= howmany(SGE_MAX_WR_LEN, 16));
MPASS(available > 0 && available < eq->sidx);
 
-   ndesc = howmany(txp->len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(txp->len16);
MPASS(ndesc <= available);
 
MPASS(wr == (void *)>desc[eq->pidx]);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364745 - in stable/12: share/man/man4 sys/dev/cxgbe sys/dev/cxgbe/common

2020-08-24 Thread Navdeep Parhar
Author: np
Date: Tue Aug 25 02:14:36 2020
New Revision: 364745
URL: https://svnweb.freebsd.org/changeset/base/364745

Log:
  MFC r351444, r357475, r357479, r357481-r357482, r358859, and r364497.
  
  All these are rx improvements in the cxgbe(4) driver.
  
  r351444:
  cxgbe(4): Use the same buffer size for TOE rx queues as the NIC rx queues.
  
  This is a minor simplification.
  
  r357475:
  cxgbe(4): Initialize the rx buffer's metadata on first-use and not on
  allocation.
  
  refill_fl doesn't touch any part of a freshly allocated cluster after
  this change.
  
  r357479:
  cxgbe(4): Avoid ext_arg2 in rxb_free.
  
  ext_arg2 is the only item in the third cacheline in an mbuf and could be
  cold by the time rxb_free runs.  Put the information needed by rxb_free
  in the same line as the refcount, which is very likely to be hot given
  that rxb_free runs when the refcount is decremented and reaches 0.
  
  r357481:
  cxgbe(4): Retire the allow_mbufs_in_cluster optimization.
  
  This simplifies the driver's rx fast path as well as the bookkeeping
  code that tracks various rx buffer sizes and layouts.
  
  r357482:
  cxgbe(4): Treat NIC rx as special and run its handler directly and not
  via the t4_cpl_handler dispatch table.
  
  r358859:
  cxgbe(4): Do not try to use 0 as an rx buffer address when the driver is
  already allocating from the safe zone and the allocation fails.
  
  This bug was introduced in r357481.
  
  r364497:
  cxgbe(4): Use large clusters for TOE rx queues when TOE+TLS is enabled.
  
  Rx is more efficient within the chip when the receive buffer size
  matches the TLS PDU size.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/share/man/man4/cxgbe.4
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/common/common.h
  stable/12/sys/dev/cxgbe/common/t4_hw.c
  stable/12/sys/dev/cxgbe/t4_main.c
  stable/12/sys/dev/cxgbe/t4_netmap.c
  stable/12/sys/dev/cxgbe/t4_sge.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/cxgbe.4
==
--- stable/12/share/man/man4/cxgbe.4Tue Aug 25 00:58:14 2020
(r364744)
+++ stable/12/share/man/man4/cxgbe.4Tue Aug 25 02:14:36 2020
(r364745)
@@ -317,11 +317,6 @@ Allow the hardware to deliver multiple frames in the s
 opportunistically.
 The default is -1 which lets the driver decide.
 0 or 1 explicitly disable or enable this feature.
-.It Va hw.cxgbe.allow_mbufs_in_cluster
-1 allows the driver to lay down one or more mbufs within the receive buffer
-opportunistically.
-This is the default.
-0 prohibits the driver from doing so.
 .It Va hw.cxgbe.largest_rx_cluster
 .It Va hw.cxgbe.safest_rx_cluster
 Sizes of rx clusters.

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Tue Aug 25 00:58:14 2020
(r364744)
+++ stable/12/sys/dev/cxgbe/adapter.h   Tue Aug 25 02:14:36 2020
(r364745)
@@ -314,24 +314,17 @@ struct port_info {
 
 #defineIS_MAIN_VI(vi)  ((vi) == &((vi)->pi->vi[0]))
 
-/* Where the cluster came from, how it has been carved up. */
-struct cluster_layout {
-   int8_t zidx;
-   int8_t hwidx;
-   uint16_t region1;   /* mbufs laid out within this region */
-   /* region2 is the DMA region */
-   uint16_t region3;   /* cluster_metadata within this region */
-};
-
 struct cluster_metadata {
+   uma_zone_t zone;
+   caddr_t cl;
u_int refcount;
-   struct fl_sdesc *sd;/* For debug only.  Could easily be stale */
 };
 
 struct fl_sdesc {
caddr_t cl;
uint16_t nmbuf; /* # of driver originated mbufs with ref on cluster */
-   struct cluster_layout cll;
+   int16_t moff;   /* offset of metadata from cl */
+   uint8_t zidx;
 };
 
 struct tx_desc {
@@ -463,20 +456,17 @@ struct sge_eq {
char lockname[16];
 };
 
-struct sw_zone_info {
+struct rx_buf_info {
uma_zone_t zone;/* zone that this cluster comes from */
-   int size;   /* size of cluster: 2K, 4K, 9K, 16K, etc. */
-   int type;   /* EXT_xxx type of the cluster */
-   int8_t head_hwidx;
-   int8_t tail_hwidx;
+   uint16_t size1; /* same as size of cluster: 2K/4K/9K/16K.
+* hwsize[hwidx1] = size1.  No spare. */
+   uint16_t size2; /* hwsize[hwidx2] = size2.
+* spare in cluster = size1 - size2. */
+   int8_t hwidx1;  /* SGE bufsize idx for size1 */
+   int8_t hwidx2;  /* SGE bufsize idx for size2 */
+   uint8_t type;   /* EXT_xxx type of the cluster */
 };
 
-struct hw_buf_info {
-   int8_t zidx;/* backpointer to zone; -ve means unused */
-   int8_t next;/* next hwidx for this zone; -1 means 

svn commit: r364497 - in head/sys/dev/cxgbe: . common

2020-08-22 Thread Navdeep Parhar
Author: np
Date: Sun Aug 23 04:16:20 2020
New Revision: 364497
URL: https://svnweb.freebsd.org/changeset/base/364497

Log:
  cxgbe(4): Use large clusters for TOE rx queues when TOE+TLS is enabled.
  
  Rx is more efficient within the chip when the receive buffer size
  matches the TLS PDU size.
  
  MFC after:3 days
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D26127

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  Sat Aug 22 22:56:50 2020
(r364496)
+++ head/sys/dev/cxgbe/common/common.h  Sun Aug 23 04:16:20 2020
(r364497)
@@ -246,6 +246,8 @@ struct tp_params {
 
uint32_t vlan_pri_map;
uint32_t ingress_config;
+   uint32_t max_rx_pdu;
+   uint32_t max_tx_pdu;
uint64_t hash_filter_mask;
__be16 err_vec_mask;
 

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Sat Aug 22 22:56:50 2020
(r364496)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Sun Aug 23 04:16:20 2020
(r364497)
@@ -9614,7 +9614,7 @@ static void read_filter_mode_and_ingress_config(struct
 int t4_init_tp_params(struct adapter *adap, bool sleep_ok)
 {
int chan;
-   u32 v;
+   u32 tx_len, rx_len, r, v;
struct tp_params *tpp = >params.tp;
 
v = t4_read_reg(adap, A_TP_TIMER_RESOLUTION);
@@ -9640,6 +9640,21 @@ int t4_init_tp_params(struct adapter *adap, bool sleep
htobe16(V_T6_COMPR_RXERR_VEC(M_T6_COMPR_RXERR_VEC));
}
}
+
+   rx_len = t4_read_reg(adap, A_TP_PMM_RX_PAGE_SIZE);
+   tx_len = t4_read_reg(adap, A_TP_PMM_TX_PAGE_SIZE);
+
+   r = t4_read_reg(adap, A_TP_PARA_REG2);
+   rx_len = min(rx_len, G_MAXRXDATA(r));
+   tx_len = min(tx_len, G_MAXRXDATA(r));
+
+   r = t4_read_reg(adap, A_TP_PARA_REG7);
+   v = min(G_PMMAXXFERLEN0(r), G_PMMAXXFERLEN1(r));
+   rx_len = min(rx_len, v);
+   tx_len = min(tx_len, v);
+
+   tpp->max_tx_pdu = tx_len;
+   tpp->max_rx_pdu = rx_len;
 
return 0;
 }

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cSat Aug 22 22:56:50 2020
(r364496)
+++ head/sys/dev/cxgbe/t4_main.cSun Aug 23 04:16:20 2020
(r364497)
@@ -736,6 +736,7 @@ static int sysctl_ulprx_la(SYSCTL_HANDLER_ARGS);
 static int sysctl_wcwr_stats(SYSCTL_HANDLER_ARGS);
 static int sysctl_cpus(SYSCTL_HANDLER_ARGS);
 #ifdef TCP_OFFLOAD
+static int sysctl_tls(SYSCTL_HANDLER_ARGS);
 static int sysctl_tls_rx_ports(SYSCTL_HANDLER_ARGS);
 static int sysctl_tp_tick(SYSCTL_HANDLER_ARGS);
 static int sysctl_tp_dack_timer(SYSCTL_HANDLER_ARGS);
@@ -6607,8 +6608,9 @@ t4_sysctls(struct adapter *sc)
CTLFLAG_RW, >tt.rx_coalesce, 0, "receive coalescing");
 
sc->tt.tls = 0;
-   SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tls", CTLFLAG_RW,
-   >tt.tls, 0, "Inline TLS allowed");
+   SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "tls", CTLTYPE_INT |
+   CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, sysctl_tls, "I",
+   "Inline TLS allowed");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "tls_rx_ports",
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
@@ -9699,6 +9701,37 @@ sysctl_cpus(SYSCTL_HANDLER_ARGS)
 }
 
 #ifdef TCP_OFFLOAD
+static int
+sysctl_tls(SYSCTL_HANDLER_ARGS)
+{
+   struct adapter *sc = arg1;
+   int i, j, v, rc;
+   struct vi_info *vi;
+
+   v = sc->tt.tls;
+   rc = sysctl_handle_int(oidp, , 0, req);
+   if (rc != 0 || req->newptr == NULL)
+   return (rc);
+
+   if (v != 0 && !(sc->cryptocaps & FW_CAPS_CONFIG_TLSKEYS))
+   return (ENOTSUP);
+
+   rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4stls");
+   if (rc)
+   return (rc);
+   sc->tt.tls = !!v;
+   for_each_port(sc, i) {
+   for_each_vi(sc->port[i], j, vi) {
+   if (vi->flags & VI_INIT_DONE)
+   t4_update_fl_bufsize(vi->ifp);
+   }
+   }
+   end_synchronized_op(sc, 0);
+
+   return (0);
+
+}
+
 static int
 sysctl_tls_rx_ports(SYSCTL_HANDLER_ARGS)
 {

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Sat Aug 22 22:56:50 2020(r364496)
+++ head/sys/dev/cxgbe/t4_sge.c Sun Aug 23 04:16:20 2020(r364497)
@@ -1032,14 +1032,19 @@ 

svn commit: r364444 - head/sys/dev/cxgbe/cxgbei

2020-08-20 Thread Navdeep Parhar
Author: np
Date: Fri Aug 21 00:34:33 2020
New Revision: 36
URL: https://svnweb.freebsd.org/changeset/base/36

Log:
  cxgbei: destroy the worker threads' CV and mutex in stop_worker_threads.
  
  Reported by:  bz@
  MFC after:3 days

Modified:
  head/sys/dev/cxgbe/cxgbei/cxgbei.c

Modified: head/sys/dev/cxgbe/cxgbei/cxgbei.c
==
--- head/sys/dev/cxgbe/cxgbei/cxgbei.c  Fri Aug 21 00:27:06 2020
(r364443)
+++ head/sys/dev/cxgbe/cxgbei/cxgbei.c  Fri Aug 21 00:34:33 2020
(r36)
@@ -715,6 +715,8 @@ stop_worker_threads(void)
cv_wait(>cwt_cv, >cwt_lock);
} while (cwt->cwt_state != CWT_STOPPED);
mtx_unlock(>cwt_lock);
+   mtx_destroy(>cwt_lock);
+   cv_destroy(>cwt_cv);
}
free(cwt_softc, M_CXGBE);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r363498 - in head/sys/dev/cxgbe: common cudbg

2020-07-24 Thread Navdeep Parhar
Author: np
Date: Fri Jul 24 23:15:42 2020
New Revision: 363498
URL: https://svnweb.freebsd.org/changeset/base/363498

Log:
  cxgbe(4): Some updates to the common code.
  
  Obtained from:Chelsio Communications
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/common/common.h
  head/sys/dev/cxgbe/common/t4_hw.c
  head/sys/dev/cxgbe/common/t4_hw.h
  head/sys/dev/cxgbe/cudbg/cudbg_lib.c

Modified: head/sys/dev/cxgbe/common/common.h
==
--- head/sys/dev/cxgbe/common/common.h  Fri Jul 24 21:14:59 2020
(r363497)
+++ head/sys/dev/cxgbe/common/common.h  Fri Jul 24 23:15:42 2020
(r363498)
@@ -299,6 +299,7 @@ struct chip_params {
u16 vfcount;
u32 sge_fl_db;
u16 mps_tcam_size;
+   u16 rss_nentries;
 };
 
 /* VF-only parameters. */
@@ -377,6 +378,7 @@ struct adapter_params {
unsigned int hash_filter:1;
unsigned int filter2_wr_support:1;
unsigned int port_caps32:1;
+   unsigned int smac_add_support:1;
 
unsigned int ofldq_wr_cred;
unsigned int eo_wr_cred;
@@ -783,8 +785,27 @@ int t4_set_rxmode(struct adapter *adap, unsigned int m
 int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox, unsigned int 
viid,
  bool free, unsigned int naddr, const u8 **addr, u16 *idx,
  u64 *hash, bool sleep_ok);
+int t4_free_mac_filt(struct adapter *adap, unsigned int mbox,
+ unsigned int viid, unsigned int naddr,
+ const u8 **addr, bool sleep_ok);
+int t4_free_encap_mac_filt(struct adapter *adap, unsigned int viid,
+  int idx, bool sleep_ok);
+int t4_free_raw_mac_filt(struct adapter *adap, unsigned int viid,
+const u8 *addr, const u8 *mask, unsigned int idx,
+u8 lookup_type, u8 port_id, bool sleep_ok);
+int t4_alloc_raw_mac_filt(struct adapter *adap, unsigned int viid,
+ const u8 *addr, const u8 *mask, unsigned int idx,
+ u8 lookup_type, u8 port_id, bool sleep_ok);
+int t4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid,
+   const u8 *addr, const u8 *mask, unsigned int vni,
+   unsigned int vni_mask, u8 dip_hit, u8 lookup_type,
+   bool sleep_ok);
 int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
  int idx, const u8 *addr, bool persist, uint16_t *smt_idx);
+int t4_del_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
+  const u8 *addr, bool smac);
+int t4_add_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
+  int idx, const u8 *addr, bool persist, u8 *smt_idx, bool smac);
 int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int 
viid,
 bool ucast, u64 vec, bool sleep_ok);
 int t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
@@ -797,6 +818,10 @@ int t4_mdio_rd(struct adapter *adap, unsigned int mbox
   unsigned int mmd, unsigned int reg, unsigned int *valp);
 int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
   unsigned int mmd, unsigned int reg, unsigned int val);
+int t4_i2c_io(struct adapter *adap, unsigned int mbox,
+ int port, unsigned int devid,
+ unsigned int offset, unsigned int len,
+ u8 *buf, bool write);
 int t4_i2c_rd(struct adapter *adap, unsigned int mbox,
  int port, unsigned int devid,
  unsigned int offset, unsigned int len,
@@ -821,7 +846,7 @@ int t4_sge_ctxt_rd(struct adapter *adap, unsigned int 
   enum ctxt_type ctype, u32 *data);
 int t4_sge_ctxt_rd_bd(struct adapter *adap, unsigned int cid, enum ctxt_type 
ctype,
  u32 *data);
-int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox);
+int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox, int ctxt_type);
 const char *t4_link_down_rc_str(unsigned char link_down_rc);
 int t4_update_port_info(struct port_info *pi);
 int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
@@ -854,6 +879,10 @@ void t4_tp_tm_pio_read(struct adapter *adap, u32 *buff
   u32 start_index, bool sleep_ok);
 void t4_tp_mib_read(struct adapter *adap, u32 *buff, u32 nregs,
u32 start_index, bool sleep_ok);
+int t4_configure_ringbb(struct adapter *adap);
+int t4_configure_add_smac(struct adapter *adap);
+int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
+   u16 vlan);
 
 static inline int t4vf_query_params(struct adapter *adapter,
unsigned int nparams, const u32 *params,

Modified: head/sys/dev/cxgbe/common/t4_hw.c

svn commit: r363167 - head/sys/dev/cxgbe

2020-07-13 Thread Navdeep Parhar
Author: np
Date: Mon Jul 13 19:15:29 2020
New Revision: 363167
URL: https://svnweb.freebsd.org/changeset/base/363167

Log:
  cxgbev(4): Compare at most 16 bytes of the Ethernet header when trying
  to coalesce tx work requests.
  
  Note that Coverity will still treat this as an out-of-bounds access.  We
  do want to compare 16B starting from ethmacdst but cmp_l2hdr was was
  going beyond that by 2B.
  
  cmp_l2hdr was introduced in r362905.
  
  Reported by:  Coverity (CID 1430284)
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Mon Jul 13 19:10:16 2020(r363166)
+++ head/sys/dev/cxgbe/t4_sge.c Mon Jul 13 19:15:29 2020(r363167)
@@ -4700,6 +4700,8 @@ csum_to_ctrl(struct adapter *sc, struct mbuf *m)
return (ctrl);
 }
 
+#define VM_TX_L2HDR_LEN16  /* ethmacdst to vlantci */
+
 /*
  * Write a VM txpkt WR for this packet to the hardware descriptors, update the
  * software descriptor, and advance the pidx.  It is guaranteed that enough
@@ -4748,7 +4750,7 @@ write_txpkt_vm_wr(struct adapter *sc, struct sge_txq *
 * conditional.  Also, it seems that we do not have to set
 * vlantci or fake the ethtype when doing VLAN tag insertion.
 */
-   m_copydata(m0, 0, sizeof(struct ether_header) + 2, wr->ethmacdst);
+   m_copydata(m0, 0, VM_TX_L2HDR_LEN, wr->ethmacdst);
 
if (needs_tso(m0)) {
struct cpl_tx_pkt_lso_core *lso = (void *)(wr + 1);
@@ -4985,10 +4987,10 @@ cmp_l2hdr(struct txpkts *txp, struct mbuf *m)
int len;
 
MPASS(txp->npkt > 0);
-   MPASS(m->m_len >= 16);  /* type1 implies 1 GL with all of the frame. */
+   MPASS(m->m_len >= VM_TX_L2HDR_LEN);
 
if (txp->ethtype == be16toh(ETHERTYPE_VLAN))
-   len = sizeof(struct ether_vlan_header);
+   len = VM_TX_L2HDR_LEN;
else
len = sizeof(struct ether_header);
 
@@ -4998,9 +5000,9 @@ cmp_l2hdr(struct txpkts *txp, struct mbuf *m)
 static inline void
 save_l2hdr(struct txpkts *txp, struct mbuf *m)
 {
-   MPASS(m->m_len >= 16);  /* type1 implies 1 GL with all of the frame. */
+   MPASS(m->m_len >= VM_TX_L2HDR_LEN);
 
-   memcpy(>ethmacdst[0], mtod(m, const void *), 16);
+   memcpy(>ethmacdst[0], mtod(m, const void *), VM_TX_L2HDR_LEN);
 }
 
 static int
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r362938 - head/sys/dev/cxgbe

2020-07-04 Thread Navdeep Parhar
Author: np
Date: Sun Jul  5 05:14:33 2020
New Revision: 362938
URL: https://svnweb.freebsd.org/changeset/base/362938

Log:
  cxgbe(4): Fix a bug (introduced in r362905) where some tx traffic wasn't
  being reported to BPF.

Modified:
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Sun Jul  5 00:19:08 2020(r362937)
+++ head/sys/dev/cxgbe/t4_sge.c Sun Jul  5 05:14:33 2020(r362938)
@@ -3013,6 +3013,7 @@ eth_tx(struct mp_ring *r, u_int cidx, u_int pidx, bool
if (avail < n)
break;  /* out of descriptors */
}
+   ETHER_BPF_MTAP(ifp, m0);
if (sc->flags & IS_VF)
n = write_txpkt_vm_wr(sc, txq, m0);
else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r362905 - in head/sys/dev/cxgbe: . common

2020-07-02 Thread Navdeep Parhar
Author: np
Date: Fri Jul  3 04:44:23 2020
New Revision: 362905
URL: https://svnweb.freebsd.org/changeset/base/362905

Log:
  cxgbe(4): changes in the Tx path to help increase tx coalescing.
  
  - Ask the firmware for the number of frames that can be stuffed in one
work request.
  
  - Modify mp_ring to increase the likelihood of tx coalescing when there
are just one or two threads that are doing most of the tx.  Add teeth
to the abdication mechanism by pushing the consumer lock into mp_ring.
This reduces the likelihood that a consumer will get stuck with all
the work even though it is above its budget.
  
  - Add support for coalesced tx WR to the VF driver.  This, with the
changes above, results in a 7x improvement in the tx pps of the VF
driver for some common cases.  The firmware vets the L2 headers
submitted by the VF driver and it's a big win if the checks are
performed for a batch of packets and not each one individually.
  
  Reviewed by:  jhb@
  MFC after:2 weeks
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D25454

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/common/common.h
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_mp_ring.c
  head/sys/dev/cxgbe/t4_mp_ring.h
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/t4_vf.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hFri Jul  3 02:02:34 2020
(r362904)
+++ head/sys/dev/cxgbe/adapter.hFri Jul  3 04:44:23 2020
(r362905)
@@ -550,6 +550,23 @@ struct sge_fl {
 
 struct mp_ring;
 
+struct txpkts {
+   uint8_t wr_type;/* type 0 or type 1 */
+   uint8_t npkt;   /* # of packets in this work request */
+   uint8_t len16;  /* # of 16B pieces used by this work request */
+   uint8_t score;  /* 1-10. coalescing attempted if score > 3 */
+   uint8_t max_npkt;   /* maximum number of packets allowed */
+   uint16_t plen;  /* total payload (sum of all packets) */
+
+   /* straight from fw_eth_tx_pkts_vm_wr. */
+   __u8   ethmacdst[6];
+   __u8   ethmacsrc[6];
+   __be16 ethtype;
+   __be16 vlantci;
+
+   struct mbuf *mb[15];
+};
+
 /* txq: SGE egress queue + what's needed for Ethernet NIC */
 struct sge_txq {
struct sge_eq eq;   /* MUST be first */
@@ -560,6 +577,7 @@ struct sge_txq {
struct sglist *gl;
__be32 cpl_ctrl0;   /* for convenience */
int tc_idx; /* traffic class */
+   struct txpkts txp;
 
struct task tx_reclaim_task;
/* stats for common events first */

Modified: head/sys/dev/cxgbe/common/common.h
==
--- head/sys/dev/cxgbe/common/common.h  Fri Jul  3 02:02:34 2020
(r362904)
+++ head/sys/dev/cxgbe/common/common.h  Fri Jul  3 04:44:23 2020
(r362905)
@@ -389,6 +389,7 @@ struct adapter_params {
bool ulptx_memwrite_dsgl;   /* use of T5 DSGL allowed */
bool fr_nsmr_tpte_wr_support;   /* FW support for FR_NSMR_TPTE_WR */
bool viid_smt_extn_support; /* FW returns vin, vfvld & smt index? */
+   unsigned int max_pkts_per_eth_tx_pkts_wr;
 };
 
 #define CHELSIO_T4 0x4

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cFri Jul  3 02:02:34 2020
(r362904)
+++ head/sys/dev/cxgbe/t4_main.cFri Jul  3 04:44:23 2020
(r362905)
@@ -2191,7 +2191,7 @@ cxgbe_transmit(struct ifnet *ifp, struct mbuf *m)
vi->rsrv_noflowq);
 
items[0] = m;
-   rc = mp_ring_enqueue(txq->r, items, 1, 4096);
+   rc = mp_ring_enqueue(txq->r, items, 1, 256);
if (__predict_false(rc != 0))
m_freem(m);
 
@@ -2212,7 +2212,7 @@ cxgbe_qflush(struct ifnet *ifp)
txq->eq.flags |= EQ_QFLUSH;
TXQ_UNLOCK(txq);
while (!mp_ring_is_idle(txq->r)) {
-   mp_ring_check_drainage(txq->r, 0);
+   mp_ring_check_drainage(txq->r, 4096);
pause("qflush", 1);
}
TXQ_LOCK(txq);
@@ -2261,7 +2261,7 @@ vi_get_counter(struct ifnet *ifp, ift_counter c)
struct sge_txq *txq;
 
for_each_txq(vi, i, txq)
-   drops += counter_u64_fetch(txq->r->drops);
+   drops += counter_u64_fetch(txq->r->dropped);
}
 
return (drops);
@@ -2326,7 +2326,7 @@ cxgbe_get_counter(struct ifnet *ifp, ift_counter c)
struct sge_txq *txq;
 

svn commit: r362616 - in head/sys/dev/cxgbe: . crypto cxgbei tom

2020-06-25 Thread Navdeep Parhar
Author: np
Date: Thu Jun 25 17:04:22 2020
New Revision: 362616
URL: https://svnweb.freebsd.org/changeset/base/362616

Log:
  cxgbe(4): Add a pointer to the adapter softc in vi_info.
  
  There were quite a few places where port_info was being accessed only to
  get to the adapter.
  
  Reviewed by:  jhb@
  MFC after:1 week
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D25432

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/crypto/t4_kern_tls.c
  head/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_netmap.c
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/t4_vf.c
  head/sys/dev/cxgbe/tom/t4_listen.c
  head/sys/dev/cxgbe/tom/t4_tom.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hThu Jun 25 16:46:27 2020
(r362615)
+++ head/sys/dev/cxgbe/adapter.hThu Jun 25 17:04:22 2020
(r362616)
@@ -190,6 +190,7 @@ enum {
 struct vi_info {
device_t dev;
struct port_info *pi;
+   struct adapter *adapter;
 
struct ifnet *ifp;
struct pfil_head *pfil;
@@ -953,22 +954,22 @@ struct adapter {
 #define TXQ_LOCK_ASSERT_NOTOWNED(txq)  EQ_LOCK_ASSERT_NOTOWNED(&(txq)->eq)
 
 #define for_each_txq(vi, iter, q) \
-   for (q = >pi->adapter->sge.txq[vi->first_txq], iter = 0; \
+   for (q = >adapter->sge.txq[vi->first_txq], iter = 0; \
iter < vi->ntxq; ++iter, ++q)
 #define for_each_rxq(vi, iter, q) \
-   for (q = >pi->adapter->sge.rxq[vi->first_rxq], iter = 0; \
+   for (q = >adapter->sge.rxq[vi->first_rxq], iter = 0; \
iter < vi->nrxq; ++iter, ++q)
 #define for_each_ofld_txq(vi, iter, q) \
-   for (q = >pi->adapter->sge.ofld_txq[vi->first_ofld_txq], iter = 0; \
+   for (q = >adapter->sge.ofld_txq[vi->first_ofld_txq], iter = 0; \
iter < vi->nofldtxq; ++iter, ++q)
 #define for_each_ofld_rxq(vi, iter, q) \
-   for (q = >pi->adapter->sge.ofld_rxq[vi->first_ofld_rxq], iter = 0; \
+   for (q = >adapter->sge.ofld_rxq[vi->first_ofld_rxq], iter = 0; \
iter < vi->nofldrxq; ++iter, ++q)
 #define for_each_nm_txq(vi, iter, q) \
-   for (q = >pi->adapter->sge.nm_txq[vi->first_nm_txq], iter = 0; \
+   for (q = >adapter->sge.nm_txq[vi->first_nm_txq], iter = 0; \
iter < vi->nnmtxq; ++iter, ++q)
 #define for_each_nm_rxq(vi, iter, q) \
-   for (q = >pi->adapter->sge.nm_rxq[vi->first_nm_rxq], iter = 0; \
+   for (q = >adapter->sge.nm_rxq[vi->first_nm_rxq], iter = 0; \
iter < vi->nnmrxq; ++iter, ++q)
 #define for_each_vi(_pi, _iter, _vi) \
for ((_vi) = (_pi)->vi, (_iter) = 0; (_iter) < (_pi)->nvi; \

Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
==
--- head/sys/dev/cxgbe/crypto/t4_kern_tls.c Thu Jun 25 16:46:27 2020
(r362615)
+++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c Thu Jun 25 17:04:22 2020
(r362616)
@@ -587,7 +587,7 @@ cxgbe_tls_tag_alloc(struct ifnet *ifp, union if_snd_ta
}
 
vi = ifp->if_softc;
-   sc = vi->pi->adapter;
+   sc = vi->adapter;
 
tlsp = alloc_tlspcb(ifp, vi, M_WAITOK);
 

Modified: head/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
==
--- head/sys/dev/cxgbe/cxgbei/icl_cxgbei.c  Thu Jun 25 16:46:27 2020
(r362615)
+++ head/sys/dev/cxgbe/cxgbei/icl_cxgbei.c  Thu Jun 25 17:04:22 2020
(r362616)
@@ -673,7 +673,7 @@ icl_cxgbei_conn_handoff(struct icl_conn *ic, int fd)
MPASS(tp->tod != NULL);
MPASS(tp->t_toe != NULL);
toep = tp->t_toe;
-   MPASS(toep->vi->pi->adapter == icc->sc);
+   MPASS(toep->vi->adapter == icc->sc);
icc->toep = toep;
icc->cwt = cxgbei_select_worker_thread(icc);
 

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cThu Jun 25 16:46:27 2020
(r362615)
+++ head/sys/dev/cxgbe/t4_main.cThu Jun 25 17:04:22 2020
(r362616)
@@ -1345,6 +1345,7 @@ t4_attach(device_t dev)
pi->nvi = num_vis;
for_each_vi(pi, j, vi) {
vi->pi = pi;
+   vi->adapter = sc;
vi->qsize_rxq = t4_qsize_rxq;
vi->qsize_txq = t4_qsize_txq;
 
@@ -1748,11 +1749,11 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
ifp->if_capabilities = T4_CAP;
ifp->if_capenable = T4_CAP_ENABLE;
 #ifdef TCP_OFFLOAD
-   if (vi->nofldrxq != 0 && (vi->pi->adapter->flags & KERN_TLS_OK) == 0)
+   if (vi->nofldrxq != 0 && (vi->adapter->flags & KERN_TLS_OK) == 0)

svn commit: r362532 - in head/sys/dev/cxgbe: . crypto

2020-06-23 Thread Navdeep Parhar
Author: np
Date: Tue Jun 23 07:33:29 2020
New Revision: 362532
URL: https://svnweb.freebsd.org/changeset/base/362532

Log:
  cxgbe(4): Add a tx_len16_to_desc helper.
  
  No functional change.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/crypto/t4_kern_tls.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hTue Jun 23 06:42:39 2020
(r362531)
+++ head/sys/dev/cxgbe/adapter.hTue Jun 23 07:33:29 2020
(r362532)
@@ -1347,4 +1347,12 @@ write_via_memwin(struct adapter *sc, int idx, uint32_t
 
return (rw_via_memwin(sc, idx, addr, (void *)(uintptr_t)val, len, 1));
 }
+
+/* Number of len16 -> number of descriptors */
+static inline int
+tx_len16_to_desc(int len16)
+{
+
+   return (howmany(len16, EQ_ESIZE / 16));
+}
 #endif

Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
==
--- head/sys/dev/cxgbe/crypto/t4_kern_tls.c Tue Jun 23 06:42:39 2020
(r362531)
+++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c Tue Jun 23 07:33:29 2020
(r362532)
@@ -1375,7 +1375,7 @@ ktls_write_tcp_options(struct sge_txq *txq, void *dst,
pktlen = m->m_len;
ctrl = sizeof(struct cpl_tx_pkt_core) + pktlen;
len16 = howmany(sizeof(struct fw_eth_tx_pkt_wr) + ctrl, 16);
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
 
/* Firmware work request header */
@@ -1475,7 +1475,7 @@ ktls_write_tunnel_packet(struct sge_txq *txq, void *ds
pktlen = m->m_len + m_tls->m_len;
ctrl = sizeof(struct cpl_tx_pkt_core) + pktlen;
len16 = howmany(sizeof(struct fw_eth_tx_pkt_wr) + ctrl, 16);
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
 
/* Firmware work request header */
@@ -2116,7 +2116,7 @@ ktls_write_tcp_fin(struct sge_txq *txq, void *dst, str
pktlen = m->m_len;
ctrl = sizeof(struct cpl_tx_pkt_core) + pktlen;
len16 = howmany(sizeof(struct fw_eth_tx_pkt_wr) + ctrl, 16);
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
 
/* Firmware work request header */

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Tue Jun 23 06:42:39 2020(r362531)
+++ head/sys/dev/cxgbe/t4_sge.c Tue Jun 23 07:33:29 2020(r362532)
@@ -2708,7 +2708,7 @@ start_wrq_wr(struct sge_wrq *wrq, int len16, struct wr
void *w;
 
MPASS(len16 > 0);
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc > 0 && ndesc <= SGE_MAX_WR_NDESC);
 
EQ_LOCK(eq);
@@ -2920,10 +2920,9 @@ eth_tx(struct mp_ring *r, u_int cidx, u_int pidx)
M_ASSERTPKTHDR(m0);
MPASS(m0->m_nextpkt == NULL);
 
-   if (available < howmany(mbuf_len16(m0), EQ_ESIZE / 16)) {
-   MPASS(howmany(mbuf_len16(m0), EQ_ESIZE / 16) <= 64);
+   if (available < tx_len16_to_desc(mbuf_len16(m0))) {
available += reclaim_tx_descs(txq, 64);
-   if (available < howmany(mbuf_len16(m0), EQ_ESIZE / 16))
+   if (available < tx_len16_to_desc(mbuf_len16(m0)))
break;  /* out of descriptors */
}
 
@@ -4678,7 +4677,7 @@ write_txpkt_vm_wr(struct adapter *sc, struct sge_txq *
ctrl = sizeof(struct cpl_tx_pkt_core);
if (needs_tso(m0))
ctrl += sizeof(struct cpl_tx_pkt_lso_core);
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
 
/* Firmware work request header */
@@ -4789,7 +4788,7 @@ write_raw_wr(struct sge_txq *txq, void *wr, struct mbu
int len16, ndesc;
 
len16 = mbuf_len16(m0);
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
 
dst = wr;
@@ -4842,7 +4841,7 @@ write_txpkt_wr(struct adapter *sc, struct sge_txq *txq
sizeof(struct cpl_tx_pkt_core) + pktlen, 16);
nsegs = 0;
}
-   ndesc = howmany(len16, EQ_ESIZE / 16);
+   ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
 
/* Firmware work request header */
@@ -4948,7 +4947,7 @@ try_txpkts(struct mbuf *m, struct mbuf *n, struct txpk
l2 = txpkts0_len16(nsegs2);
}
txp->len16 = howmany(sizeof(struct fw_eth_tx_pkts_wr), 16) + l1 + l2;
-   needed = howmany(txp->len16, EQ_ESIZE / 

svn commit: r361261 - in head/sys/dev/cxgbe: . iw_cxgbe

2020-05-19 Thread Navdeep Parhar
Author: np
Date: Tue May 19 16:28:20 2020
New Revision: 361261
URL: https://svnweb.freebsd.org/changeset/base/361261

Log:
  cxgbe/iw_cxgbe: Add an async callback to notify iw_cxgbe in case of a
  fatal error.
  
  Submitted by: Krishnamraju Eraparaju @ Chelsio
  MFC after:2 weeks
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/iw_cxgbe/cm.c
  head/sys/dev/cxgbe/iw_cxgbe/device.c
  head/sys/dev/cxgbe/offload.h
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hTue May 19 16:06:03 2020
(r361260)
+++ head/sys/dev/cxgbe/adapter.hTue May 19 16:28:20 2020
(r361261)
@@ -830,6 +830,7 @@ struct adapter {
int sc_do_rxcopy;
 
struct taskqueue *tq[MAX_NCHAN];/* General purpose taskqueues */
+   struct task async_event_task;
struct port_info *port[MAX_NPORTS];
uint8_t chan_map[MAX_NCHAN];/* channel -> port */
 

Modified: head/sys/dev/cxgbe/iw_cxgbe/cm.c
==
--- head/sys/dev/cxgbe/iw_cxgbe/cm.cTue May 19 16:06:03 2020
(r361260)
+++ head/sys/dev/cxgbe/iw_cxgbe/cm.cTue May 19 16:28:20 2020
(r361261)
@@ -1085,7 +1085,7 @@ c4iw_so_upcall(struct socket *so, void *arg, int waitf
 * Wake up any threads waiting in rdma_init()/rdma_fini(),
 * with locks held.
 */
-   if (so->so_error)
+   if (so->so_error || (ep->com.dev->rdev.flags & T4_FATAL_ERROR))
c4iw_wake_up(>com.wr_wait, -ECONNRESET);
add_ep_to_req_list(ep, C4IW_EVENT_SOCKET);
 
@@ -2700,6 +2700,11 @@ c4iw_create_listen(struct iw_cm_id *cm_id, int backlog
 
CTR3(KTR_IW_CXGBE, "%s: cm_id %p, backlog %s", __func__, cm_id,
backlog);
+   if (c4iw_fatal_error(>rdev)) {
+   CTR2(KTR_IW_CXGBE, "%s: cm_id %p, fatal error", __func__,
+  cm_id);
+   return -EIO;
+   }
lep = alloc_ep(sizeof(*lep), GFP_KERNEL);
lep->com.cm_id = cm_id;
ref_cm_id(>com);
@@ -2800,7 +2805,6 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt,
 {
int ret = 0;
int close = 0;
-   int fatal = 0;
struct c4iw_rdev *rdev;
 
 
@@ -2809,12 +2813,14 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt,
rdev = >com.dev->rdev;
 
if (c4iw_fatal_error(rdev)) {
-
-   CTR2(KTR_IW_CXGBE, "%s:ced1 %p", __func__, ep);
-   fatal = 1;
+   CTR3(KTR_IW_CXGBE, "%s:ced1 fatal error %p %s", __func__, ep,
+   states[ep->com.state]);
+   if (ep->com.state != DEAD) {
+   send_abort(ep);
+   ep->com.state = DEAD;
+   }
close_complete_upcall(ep, -ECONNRESET);
-   send_abort(ep);
-   ep->com.state = DEAD;
+   return ECONNRESET;
}
CTR3(KTR_IW_CXGBE, "%s:ced2 %p %s", __func__, ep,
states[ep->com.state]);
@@ -2877,9 +2883,7 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt,
CTR2(KTR_IW_CXGBE, "%s:ced4 %p", __func__, ep);
set_bit(EP_DISC_ABORT, >com.history);
close_complete_upcall(ep, -ECONNRESET);
-   ret = send_abort(ep);
-   if (ret)
-   fatal = 1;
+   send_abort(ep);
} else {
 
CTR2(KTR_IW_CXGBE, "%s:ced5 %p", __func__, ep);
@@ -2889,33 +2893,28 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt,
ep->com.state = MORIBUND;
 
CURVNET_SET(ep->com.so->so_vnet);
-   sodisconnect(ep->com.so);
+   ret = sodisconnect(ep->com.so);
CURVNET_RESTORE();
-   }
-
-   }
-
-   if (fatal) {
-   set_bit(EP_DISC_FAIL, >com.history);
-   if (!abrupt) {
-   STOP_EP_TIMER(ep);
-   close_complete_upcall(ep, -EIO);
-   }
-   if (ep->com.qp) {
-   struct c4iw_qp_attributes attrs = {0};
-
-   attrs.next_state = C4IW_QP_STATE_ERROR;
-   ret = c4iw_modify_qp(ep->com.dev, ep->com.qp,
-   C4IW_QP_ATTR_NEXT_STATE,
-   , 1);
if (ret) {
-   CTR2(KTR_IW_CXGBE, "%s:ced7 %p", __func__, ep);
-   printf("%s - qp <- error failed!\n", __func__);
+   CTR2(KTR_IW_CXGBE, "%s:ced6 %p", 

Re: svn commit: r360581 - in head/sys: dev/cxgbe dev/cxgbe/crypto dev/cxgbe/tom dev/mlx5/mlx5_en kern netinet sys

2020-05-02 Thread Navdeep Parhar
On Sun, May 03, 2020 at 12:21:11AM +, Gleb Smirnoff wrote:
> Author: glebius
> Date: Sun May  3 00:21:11 2020
> New Revision: 360581
> URL: https://svnweb.freebsd.org/changeset/base/360581
> 
> Log:
>   Step 4.1: mechanically rename M_NOMAP to M_EXTPG

Hello Gleb,

This looks incomplete.  mbuf.9 still refers to M_NOMAP.  ifnet cap is
still IFCAP_NOMAP and shown as NOMAP by ifconfig, and ifconfig still
uses (-)nomap to enable/disable the capability.

This looks a bit gratuitous to me but if you're going to do it then at
least use the same name consistently throughout the tree.

Regards,
Navdeep

>   
>   Reviewed by:gallatin
>   Differential Revision:  https://reviews.freebsd.org/D24598
> 
> Modified:
>   head/sys/dev/cxgbe/crypto/t4_kern_tls.c
>   head/sys/dev/cxgbe/t4_sge.c
>   head/sys/dev/cxgbe/tom/t4_cpl_io.c
>   head/sys/dev/cxgbe/tom/t4_tls.c
>   head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
>   head/sys/kern/kern_mbuf.c
>   head/sys/kern/kern_sendfile.c
>   head/sys/kern/subr_bus_dma.c
>   head/sys/kern/subr_sglist.c
>   head/sys/kern/uipc_ktls.c
>   head/sys/kern/uipc_mbuf.c
>   head/sys/kern/uipc_sockbuf.c
>   head/sys/kern/uipc_socket.c
>   head/sys/netinet/tcp_output.c
>   head/sys/netinet/tcp_pcap.c
>   head/sys/sys/mbuf.h
> 
> Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
> ==
> --- head/sys/dev/cxgbe/crypto/t4_kern_tls.c   Sun May  3 00:15:18 2020
> (r360580)
> +++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c   Sun May  3 00:21:11 2020
> (r360581)
> @@ -1208,7 +1208,7 @@ t6_ktls_parse_pkt(struct mbuf *m, int *nsegsp, int *le
>  
>   /* Assume all headers are in 'm' for now. */
>   MPASS(m->m_next != NULL);
> - MPASS(m->m_next->m_flags & M_NOMAP);
> + MPASS(m->m_next->m_flags & M_EXTPG);
>  
>   tot_len = 0;
>  
> @@ -1218,7 +1218,7 @@ t6_ktls_parse_pkt(struct mbuf *m, int *nsegsp, int *le
>*/
>   *nsegsp = 0;
>   for (m_tls = m->m_next; m_tls != NULL; m_tls = m_tls->m_next) {
> - MPASS(m_tls->m_flags & M_NOMAP);
> + MPASS(m_tls->m_flags & M_EXTPG);
>  
>   wr_len = ktls_wr_len(tlsp, m, m_tls, );
>  #ifdef VERBOSE_TRACES
> @@ -2265,7 +2265,7 @@ t6_ktls_write_wr(struct sge_txq *txq, void *dst, struc
>* for that record.
>*/
>   for (m_tls = m->m_next; m_tls != NULL; m_tls = m_tls->m_next) {
> - MPASS(m_tls->m_flags & M_NOMAP);
> + MPASS(m_tls->m_flags & M_EXTPG);
>  
>   /*
>* Determine the initial TCP sequence number for this
> 
> Modified: head/sys/dev/cxgbe/t4_sge.c
> ==
> --- head/sys/dev/cxgbe/t4_sge.c   Sun May  3 00:15:18 2020
> (r360580)
> +++ head/sys/dev/cxgbe/t4_sge.c   Sun May  3 00:21:11 2020
> (r360581)
> @@ -2497,7 +2497,7 @@ count_mbuf_nsegs(struct mbuf *m, int skip, uint8_t *cf
>   skip -= len;
>   continue;
>   }
> - if ((m->m_flags & M_NOMAP) != 0) {
> + if ((m->m_flags & M_EXTPG) != 0) {
>   *cflags |= MC_NOMAP;
>   nsegs += count_mbuf_ext_pgs(m, skip, );
>   skip = 0;
> @@ -5836,7 +5836,7 @@ write_ethofld_wr(struct cxgbe_rate_tag *cst, struct fw
>   immhdrs -= m0->m_len;
>   continue;
>   }
> - if (m0->m_flags & M_NOMAP)
> + if (m0->m_flags & M_EXTPG)
>   sglist_append_mbuf_epg(, m0,
>   mtod(m0, vm_offset_t), m0->m_len);
>  else
> 
> Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c
> ==
> --- head/sys/dev/cxgbe/tom/t4_cpl_io.cSun May  3 00:15:18 2020
> (r360580)
> +++ head/sys/dev/cxgbe/tom/t4_cpl_io.cSun May  3 00:21:11 2020
> (r360581)
> @@ -610,7 +610,7 @@ write_tx_sgl(void *dst, struct mbuf *start, struct mbu
>  
>   i = -1;
>   for (m = start; m != stop; m = m->m_next) {
> - if (m->m_flags & M_NOMAP)
> + if (m->m_flags & M_EXTPG)
>   rc = sglist_append_mbuf_epg(, m,
>   mtod(m, vm_offset_t), m->m_len);
>   else
> @@ -731,7 +731,7 @@ t4_push_frames(struct adapter *sc, struct toepcb *toep
>   for (m = sndptr; m != NULL; m = m->m_next) {
>   int n;
>  
> - if (m->m_flags & M_NOMAP) {
> + if (m->m_flags & M_EXTPG) {
>  #ifdef KERN_TLS
>   if (m->m_epg_tls != NULL) {
>   toep->flags |= TPF_KTLS;
> @@ -772,7 +772,7 @@ t4_push_frames(struct adapter *sc, struct toepcb *toep
> 

svn commit: r360548 - stable/12/sys/dev/cxgbe/iw_cxgbe

2020-05-01 Thread Navdeep Parhar
Author: np
Date: Fri May  1 21:22:26 2020
New Revision: 360548
URL: https://svnweb.freebsd.org/changeset/base/360548

Log:
  MFC r360211:
  
  cxgbe/iw_cxgbe: Create a LinuxKPI pci device for an adapter and use it
  as the dma_device during RDMA registration.
  
  cxgbe's struct device cannot be used as-is because it's a native FreeBSD
  driver and ibcore is LinuxKPI based.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
  stable/12/sys/dev/cxgbe/iw_cxgbe/provider.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
==
--- stable/12/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h Fri May  1 20:29:51 2020
(r360547)
+++ stable/12/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h Fri May  1 21:22:26 2020
(r360548)
@@ -261,6 +261,7 @@ out:
 
 struct c4iw_dev {
struct ib_device ibdev;
+   struct pci_dev pdev;
struct c4iw_rdev rdev;
u32 device_cap_flags;
struct idr cqidr;

Modified: stable/12/sys/dev/cxgbe/iw_cxgbe/provider.c
==
--- stable/12/sys/dev/cxgbe/iw_cxgbe/provider.c Fri May  1 20:29:51 2020
(r360547)
+++ stable/12/sys/dev/cxgbe/iw_cxgbe/provider.c Fri May  1 21:22:26 2020
(r360548)
@@ -434,6 +434,9 @@ c4iw_register_device(struct c4iw_dev *dev)
 
CTR3(KTR_IW_CXGBE, "%s c4iw_dev %p, adapter %p", __func__, dev, sc);
BUG_ON(!sc->port[0]);
+   ret = linux_pci_attach_device(sc->dev, NULL, NULL, >pdev);
+   if (ret)
+   return (ret);
strlcpy(ibdev->name, device_get_nameunit(sc->dev), sizeof(ibdev->name));
memset(>node_guid, 0, sizeof(ibdev->node_guid));
memcpy(>node_guid, sc->port[0]->vi[0].hw_addr, ETHER_ADDR_LEN);
@@ -465,7 +468,7 @@ c4iw_register_device(struct c4iw_dev *dev)
strlcpy(ibdev->node_desc, C4IW_NODE_DESC, sizeof(ibdev->node_desc));
ibdev->phys_port_cnt = sc->params.nports;
ibdev->num_comp_vectors = 1;
-   ibdev->dma_device = NULL;
+   ibdev->dma_device = >pdev.dev;
ibdev->query_device = c4iw_query_device;
ibdev->query_port = c4iw_query_port;
ibdev->modify_port = c4iw_modify_port;
@@ -517,8 +520,10 @@ c4iw_register_device(struct c4iw_dev *dev)
ibdev->iwcm = iwcm;
 
ret = ib_register_device(>ibdev, NULL);
-   if (ret)
+   if (ret) {
kfree(iwcm);
+   linux_pci_detach_device(>pdev);
+   }
 
return (ret);
 }
@@ -531,6 +536,7 @@ c4iw_unregister_device(struct c4iw_dev *dev)
dev->rdev.adap);
ib_unregister_device(>ibdev);
kfree(dev->ibdev.iwcm);
+   linux_pci_detach_device(>pdev);
return;
 }
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r360232 - head/sys/dev/cxgbe/crypto

2020-04-23 Thread Navdeep Parhar
Author: np
Date: Thu Apr 23 23:54:23 2020
New Revision: 360232
URL: https://svnweb.freebsd.org/changeset/base/360232

Log:
  cxgbe/crypto: Fix the key size in a couple of places to catch up with
  the recent OCF refactor.
  
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/crypto/t4_kern_tls.c

Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
==
--- head/sys/dev/cxgbe/crypto/t4_kern_tls.c Thu Apr 23 21:16:51 2020
(r360231)
+++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c Thu Apr 23 23:54:23 2020
(r360232)
@@ -812,11 +812,11 @@ ktls_setup_keys(struct tlspcb *tlsp, const struct ktls
if (tlsp->enc_mode == SCMD_CIPH_MODE_AES_GCM) {
memcpy(khdr->txsalt, tls->params.iv, SALT_SIZE);
t4_init_gmac_hash(tls->params.cipher_key,
-   tls->params.cipher_key_len * 8,
+   tls->params.cipher_key_len,
(char *)key + tls->params.cipher_key_len);
} else {
t4_init_hmac_digest(axf, partial_digest_len,
-   tls->params.auth_key, tls->params.auth_key_len * 8,
+   tls->params.auth_key, tls->params.auth_key_len,
(char *)key + tls->params.cipher_key_len);
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r360211 - head/sys/dev/cxgbe/iw_cxgbe

2020-04-22 Thread Navdeep Parhar
Author: np
Date: Wed Apr 22 21:54:21 2020
New Revision: 360211
URL: https://svnweb.freebsd.org/changeset/base/360211

Log:
  cxgbe/iw_cxgbe: Create a LinuxKPI pci device for an adapter and use it
  as the dma_device during RDMA registration.
  
  cxgbe's struct device cannot be used as-is because it's a native FreeBSD
  driver and ibcore is LinuxKPI based.
  
  MFC after:1 week
  MFC after:r360196

Modified:
  head/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
  head/sys/dev/cxgbe/iw_cxgbe/provider.c

Modified: head/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
==
--- head/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h  Wed Apr 22 21:45:43 2020
(r360210)
+++ head/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h  Wed Apr 22 21:54:21 2020
(r360211)
@@ -261,6 +261,7 @@ out:
 
 struct c4iw_dev {
struct ib_device ibdev;
+   struct pci_dev pdev;
struct c4iw_rdev rdev;
u32 device_cap_flags;
struct idr cqidr;

Modified: head/sys/dev/cxgbe/iw_cxgbe/provider.c
==
--- head/sys/dev/cxgbe/iw_cxgbe/provider.c  Wed Apr 22 21:45:43 2020
(r360210)
+++ head/sys/dev/cxgbe/iw_cxgbe/provider.c  Wed Apr 22 21:54:21 2020
(r360211)
@@ -434,6 +434,9 @@ c4iw_register_device(struct c4iw_dev *dev)
 
CTR3(KTR_IW_CXGBE, "%s c4iw_dev %p, adapter %p", __func__, dev, sc);
BUG_ON(!sc->port[0]);
+   ret = linux_pci_attach_device(sc->dev, NULL, NULL, >pdev);
+   if (ret)
+   return (ret);
strlcpy(ibdev->name, device_get_nameunit(sc->dev), sizeof(ibdev->name));
memset(>node_guid, 0, sizeof(ibdev->node_guid));
memcpy(>node_guid, sc->port[0]->vi[0].hw_addr, ETHER_ADDR_LEN);
@@ -465,7 +468,7 @@ c4iw_register_device(struct c4iw_dev *dev)
strlcpy(ibdev->node_desc, C4IW_NODE_DESC, sizeof(ibdev->node_desc));
ibdev->phys_port_cnt = sc->params.nports;
ibdev->num_comp_vectors = 1;
-   ibdev->dma_device = NULL;
+   ibdev->dma_device = >pdev.dev;
ibdev->query_device = c4iw_query_device;
ibdev->query_port = c4iw_query_port;
ibdev->modify_port = c4iw_modify_port;
@@ -517,8 +520,10 @@ c4iw_register_device(struct c4iw_dev *dev)
ibdev->iwcm = iwcm;
 
ret = ib_register_device(>ibdev, NULL);
-   if (ret)
+   if (ret) {
kfree(iwcm);
+   linux_pci_detach_device(>pdev);
+   }
 
return (ret);
 }
@@ -531,6 +536,7 @@ c4iw_unregister_device(struct c4iw_dev *dev)
dev->rdev.adap);
ib_unregister_device(>ibdev);
kfree(dev->ibdev.iwcm);
+   linux_pci_detach_device(>pdev);
return;
 }
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r360189 - stable/12/sys/dev/cxgbe/tom

2020-04-22 Thread Navdeep Parhar
Author: np
Date: Wed Apr 22 07:24:30 2020
New Revision: 360189
URL: https://svnweb.freebsd.org/changeset/base/360189

Log:
  MFC r359897:
  
  cxgbe(4): Make sure 'flags' is at the same offset in structs toepcb and
  synq_entry.  TAILQ_ENTRY isn't always the same size as two pointers.
  
  Reported by:  rmacklem@
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/tom/t4_tom.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/tom/t4_tom.h
==
--- stable/12/sys/dev/cxgbe/tom/t4_tom.hWed Apr 22 07:12:18 2020
(r360188)
+++ stable/12/sys/dev/cxgbe/tom/t4_tom.hWed Apr 22 07:24:30 2020
(r360189)
@@ -187,11 +187,11 @@ struct aiotx_buffer {
 };
 
 struct toepcb {
-   TAILQ_ENTRY(toepcb) link; /* toep_list */
-   u_int flags;/* miscellaneous flags */
-   int refcount;
struct tom_data *td;
struct inpcb *inp;  /* backpointer to host stack's PCB */
+   u_int flags;/* miscellaneous flags */
+   TAILQ_ENTRY(toepcb) link; /* toep_list */
+   int refcount;
struct vnet *vnet;
struct vi_info *vi; /* virtual interface */
struct sge_wrq *ofld_txq;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r360188 - stable/12/sys/dev/cxgbe/iw_cxgbe

2020-04-22 Thread Navdeep Parhar
Author: np
Date: Wed Apr 22 07:12:18 2020
New Revision: 360188
URL: https://svnweb.freebsd.org/changeset/base/360188

Log:
  MFC r359952:
  
  cxgbe/iw_cxgbe: Do not start the EP timer if soaccept fails.
  
  This fixes a panic that would occur when the timer tried to close a
  stale socket.
  
  Submitted by: Krishnamraju Eraparaju @ Chelsio
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/iw_cxgbe/cm.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/iw_cxgbe/cm.c
==
--- stable/12/sys/dev/cxgbe/iw_cxgbe/cm.c   Wed Apr 22 06:32:51 2020
(r360187)
+++ stable/12/sys/dev/cxgbe/iw_cxgbe/cm.c   Wed Apr 22 07:12:18 2020
(r360188)
@@ -1013,7 +1013,6 @@ process_newconn(struct c4iw_listen_ep *master_lep, str
c4iw_get_ep(_lep->com);
init_timer(_ep->timer);
new_ep->com.state = MPA_REQ_WAIT;
-   START_EP_TIMER(new_ep);
 
setiwsockopt(new_so);
ret = soaccept(new_so, (struct sockaddr **));
@@ -1023,13 +1022,14 @@ process_newconn(struct c4iw_listen_ep *master_lep, str
__func__, master_lep->com.so, new_so, ret);
if (remote != NULL)
free(remote, M_SONAME);
-   uninit_iwarp_socket(new_so);
soclose(new_so);
c4iw_put_ep(_ep->com);
c4iw_put_ep(_lep->com);
return;
}
free(remote, M_SONAME);
+
+   START_EP_TIMER(new_ep);
 
/* MPA request might have been queued up on the socket already, so we
 * initialize the socket/upcall_handler under lock to prevent processing
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359952 - head/sys/dev/cxgbe/iw_cxgbe

2020-04-14 Thread Navdeep Parhar
Author: np
Date: Wed Apr 15 03:40:33 2020
New Revision: 359952
URL: https://svnweb.freebsd.org/changeset/base/359952

Log:
  cxgbe/iw_cxgbe: Do not start the EP timer if soaccept fails.
  
  This fixes a panic that would occur when the timer tried to close a
  stale socket.
  
  Submitted by: Krishnamraju Eraparaju @ Chelsio
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/iw_cxgbe/cm.c

Modified: head/sys/dev/cxgbe/iw_cxgbe/cm.c
==
--- head/sys/dev/cxgbe/iw_cxgbe/cm.cWed Apr 15 02:34:44 2020
(r359951)
+++ head/sys/dev/cxgbe/iw_cxgbe/cm.cWed Apr 15 03:40:33 2020
(r359952)
@@ -1013,7 +1013,6 @@ process_newconn(struct c4iw_listen_ep *master_lep, str
c4iw_get_ep(_lep->com);
init_timer(_ep->timer);
new_ep->com.state = MPA_REQ_WAIT;
-   START_EP_TIMER(new_ep);
 
setiwsockopt(new_so);
ret = soaccept(new_so, (struct sockaddr **));
@@ -1023,13 +1022,14 @@ process_newconn(struct c4iw_listen_ep *master_lep, str
__func__, master_lep->com.so, new_so, ret);
if (remote != NULL)
free(remote, M_SONAME);
-   uninit_iwarp_socket(new_so);
soclose(new_so);
c4iw_put_ep(_ep->com);
c4iw_put_ep(_lep->com);
return;
}
free(remote, M_SONAME);
+
+   START_EP_TIMER(new_ep);
 
/* MPA request might have been queued up on the socket already, so we
 * initialize the socket/upcall_handler under lock to prevent processing
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359897 - head/sys/dev/cxgbe/tom

2020-04-13 Thread Navdeep Parhar
Author: np
Date: Mon Apr 13 20:12:47 2020
New Revision: 359897
URL: https://svnweb.freebsd.org/changeset/base/359897

Log:
  cxgbe(4): Make sure 'flags' is at the same offset in structs toepcb and
  synq_entry.  TAILQ_ENTRY isn't always the same size as two pointers.
  
  Reported by:  rmacklem@
  MFC after:3 days
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/tom/t4_tom.h

Modified: head/sys/dev/cxgbe/tom/t4_tom.h
==
--- head/sys/dev/cxgbe/tom/t4_tom.h Mon Apr 13 20:00:44 2020
(r359896)
+++ head/sys/dev/cxgbe/tom/t4_tom.h Mon Apr 13 20:12:47 2020
(r359897)
@@ -176,11 +176,11 @@ struct ddp_pcb {
 };
 
 struct toepcb {
-   TAILQ_ENTRY(toepcb) link; /* toep_list */
-   u_int flags;/* miscellaneous flags */
-   int refcount;
struct tom_data *td;
struct inpcb *inp;  /* backpointer to host stack's PCB */
+   u_int flags;/* miscellaneous flags */
+   TAILQ_ENTRY(toepcb) link; /* toep_list */
+   int refcount;
struct vnet *vnet;
struct vi_info *vi; /* virtual interface */
struct sge_wrq *ofld_txq;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359351 - stable/12/sys/dev/cxgbe

2020-03-26 Thread Navdeep Parhar
Author: np
Date: Fri Mar 27 03:58:00 2020
New Revision: 359351
URL: https://svnweb.freebsd.org/changeset/base/359351

Log:
  MFC r359159:
  
  cxgbe(4): Split sge_nm_rxq into three cachelines.
  
  This reduces the lines bouncing around between the driver rx ithread and
  the netmap rxsync thread.  There is no net change in the size of the
  struct (it continues to waste a lot of space).
  
  This kind of split was originally proposed in D17869 by Marc De La
  Gueronniere @ Verisign, Inc.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/t4_netmap.c
  stable/12/sys/dev/cxgbe/t4_sge.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/adapter.h
==
--- stable/12/sys/dev/cxgbe/adapter.h   Fri Mar 27 03:18:52 2020
(r359350)
+++ stable/12/sys/dev/cxgbe/adapter.h   Fri Mar 27 03:58:00 2020
(r359351)
@@ -677,7 +677,9 @@ struct sge_wrq {
 
 #define INVALID_NM_RXQ_CNTXT_ID ((uint16_t)(-1))
 struct sge_nm_rxq {
-   volatile int nm_state;  /* NM_OFF, NM_ON, or NM_BUSY */
+   /* Items used by the driver rx ithread are in this cacheline. */
+   volatile int nm_state __aligned(CACHE_LINE_SIZE);   /* NM_OFF, 
NM_ON, or NM_BUSY */
+   u_int nid;  /* netmap ring # for this queue */
struct vi_info *vi;
 
struct iq_desc *iq_desc;
@@ -686,20 +688,23 @@ struct sge_nm_rxq {
uint16_t iq_cidx;
uint16_t iq_sidx;
uint8_t iq_gen;
+   uint32_t fl_sidx;
 
-   __be64  *fl_desc;
+   /* Items used by netmap rxsync are in this cacheline. */
+   __be64  *fl_desc __aligned(CACHE_LINE_SIZE);
uint16_t fl_cntxt_id;
-   uint32_t fl_cidx;
uint32_t fl_pidx;
-   uint32_t fl_sidx;
+   uint32_t fl_sidx2;  /* copy of fl_sidx */
uint32_t fl_db_val;
+   u_int fl_db_saved;
u_int fl_hwidx:4;
 
-   u_int fl_db_saved;
-   u_int nid;  /* netmap ring # for this queue */
+   /*
+* fl_cidx is used by both the ithread and rxsync, the rest are not used
+* in the rx fast path.
+*/
+   uint32_t fl_cidx __aligned(CACHE_LINE_SIZE);
 
-   /* infrequently used items after this */
-
bus_dma_tag_t iq_desc_tag;
bus_dmamap_t iq_desc_map;
bus_addr_t iq_ba;
@@ -708,7 +713,7 @@ struct sge_nm_rxq {
bus_dma_tag_t fl_desc_tag;
bus_dmamap_t fl_desc_map;
bus_addr_t fl_ba;
-} __aligned(CACHE_LINE_SIZE);
+};
 
 #define INVALID_NM_TXQ_CNTXT_ID ((u_int)(-1))
 struct sge_nm_txq {

Modified: stable/12/sys/dev/cxgbe/t4_netmap.c
==
--- stable/12/sys/dev/cxgbe/t4_netmap.c Fri Mar 27 03:18:52 2020
(r359350)
+++ stable/12/sys/dev/cxgbe/t4_netmap.c Fri Mar 27 03:58:00 2020
(r359351)
@@ -916,7 +916,7 @@ cxgbe_netmap_rxsync(struct netmap_kring *kring, int fl
MPASS((n & 7) == 0);
 
IDXINCR(kring->nr_hwcur, n, kring->nkr_num_slots);
-   IDXINCR(nm_rxq->fl_pidx, n, nm_rxq->fl_sidx);
+   IDXINCR(nm_rxq->fl_pidx, n, nm_rxq->fl_sidx2);
 
while (n > 0) {
for (i = 0; i < 8; i++, fl_pidx++, slot++) {
@@ -924,10 +924,10 @@ cxgbe_netmap_rxsync(struct netmap_kring *kring, int fl
MPASS(ba != 0);
nm_rxq->fl_desc[fl_pidx] = htobe64(ba | hwidx);
slot->flags &= ~NS_BUF_CHANGED;
-   MPASS(fl_pidx <= nm_rxq->fl_sidx);
+   MPASS(fl_pidx <= nm_rxq->fl_sidx2);
}
n -= 8;
-   if (fl_pidx == nm_rxq->fl_sidx) {
+   if (fl_pidx == nm_rxq->fl_sidx2) {
fl_pidx = 0;
slot = >slot[0];
}

Modified: stable/12/sys/dev/cxgbe/t4_sge.c
==
--- stable/12/sys/dev/cxgbe/t4_sge.cFri Mar 27 03:18:52 2020
(r359350)
+++ stable/12/sys/dev/cxgbe/t4_sge.cFri Mar 27 03:58:00 2020
(r359351)
@@ -3587,6 +3587,7 @@ alloc_nm_rxq(struct vi_info *vi, struct sge_nm_rxq *nm
nm_rxq->iq_gen = F_RSPD_GEN;
nm_rxq->fl_pidx = nm_rxq->fl_cidx = 0;
nm_rxq->fl_sidx = na->num_rx_desc;
+   nm_rxq->fl_sidx2 = nm_rxq->fl_sidx; /* copy for rxsync cacheline */
nm_rxq->intr_idx = intr_idx;
nm_rxq->iq_cntxt_id = INVALID_NM_RXQ_CNTXT_ID;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359313 - stable/12/sys/dev/pci

2020-03-25 Thread Navdeep Parhar
Author: np
Date: Thu Mar 26 00:39:36 2020
New Revision: 359313
URL: https://svnweb.freebsd.org/changeset/base/359313

Log:
  MFC r359057:
  
  Remove spurious warning about invalid VPD data.
  
  The warning used to be displayed for valid VPDs about 512B or above in
  size.  Fix the size check and add a break while here so that the routine
  stops if if detects any problem.
  
  Tested with "pciconf -lV"
  
  Reviewed by:  kib@, jhb@
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D23679

Modified:
  stable/12/sys/dev/pci/pci.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/pci/pci.c
==
--- stable/12/sys/dev/pci/pci.c Thu Mar 26 00:31:21 2020(r359312)
+++ stable/12/sys/dev/pci/pci.c Thu Mar 26 00:39:36 2020(r359313)
@@ -1105,16 +1105,16 @@ pci_read_vpd(device_t pcib, pcicfgregs *cfg)
break;
}
remain |= byte2 << 8;
-   if (remain > (0x7f*4 - vrs.off)) {
-   state = -1;
-   pci_printf(cfg,
-   "invalid VPD data, remain %#x\n",
-   remain);
-   }
name = byte & 0x7f;
} else {
remain = byte & 0x7;
name = (byte >> 3) & 0xf;
+   }
+   if (vrs.off + remain - vrs.bytesinval > 0x8000) {
+   pci_printf(cfg,
+   "VPD data overflow, remain %#x\n", remain);
+   state = -1;
+   break;
}
switch (name) {
case 0x2:   /* String */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359312 - stable/12/sys/dev/cxgbe/tom

2020-03-25 Thread Navdeep Parhar
Author: np
Date: Thu Mar 26 00:31:21 2020
New Revision: 359312
URL: https://svnweb.freebsd.org/changeset/base/359312

Log:
  MFC r358860:
  
  cxgbe/t4_tom: The MSS in a FLOWC work request must not be 0.
  
  Submitted by: jhb@
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/tom/t4_cpl_io.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- stable/12/sys/dev/cxgbe/tom/t4_cpl_io.c Wed Mar 25 23:12:43 2020
(r359311)
+++ stable/12/sys/dev/cxgbe/tom/t4_cpl_io.c Thu Mar 26 00:31:21 2020
(r359312)
@@ -156,11 +156,12 @@ send_flowc_wr(struct toepcb *toep, struct tcpcb *tp)
FLOWC_PARAM(PORT, pi->tx_chan);
FLOWC_PARAM(IQID, toep->ofld_rxq->iq.abs_id);
FLOWC_PARAM(SNDBUF, toep->params.sndbuf);
-   FLOWC_PARAM(MSS, toep->params.emss);
if (tp) {
+   FLOWC_PARAM(MSS, toep->params.emss);
FLOWC_PARAM(SNDNXT, tp->snd_nxt);
FLOWC_PARAM(RCVNXT, tp->rcv_nxt);
-   }
+   } else
+   FLOWC_PARAM(MSS, 512);
CTR6(KTR_CXGBE,
"%s: tid %u, mss %u, sndbuf %u, snd_nxt 0x%x, rcv_nxt 0x%x",
__func__, toep->tid, toep->params.emss, toep->params.sndbuf,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359159 - head/sys/dev/cxgbe

2020-03-19 Thread Navdeep Parhar
Author: np
Date: Fri Mar 20 05:12:16 2020
New Revision: 359159
URL: https://svnweb.freebsd.org/changeset/base/359159

Log:
  cxgbe(4): Split sge_nm_rxq into three cachelines.
  
  This reduces the lines bouncing around between the driver rx ithread and
  the netmap rxsync thread.  There is no net change in the size of the
  struct (it continues to waste a lot of space).
  
  This kind of split was originally proposed in D17869 by Marc De La
  Gueronniere @ Verisign, Inc.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/t4_netmap.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hFri Mar 20 04:13:39 2020
(r359158)
+++ head/sys/dev/cxgbe/adapter.hFri Mar 20 05:12:16 2020
(r359159)
@@ -685,7 +685,9 @@ struct sge_wrq {
 
 #define INVALID_NM_RXQ_CNTXT_ID ((uint16_t)(-1))
 struct sge_nm_rxq {
-   volatile int nm_state;  /* NM_OFF, NM_ON, or NM_BUSY */
+   /* Items used by the driver rx ithread are in this cacheline. */
+   volatile int nm_state __aligned(CACHE_LINE_SIZE);   /* NM_OFF, 
NM_ON, or NM_BUSY */
+   u_int nid;  /* netmap ring # for this queue */
struct vi_info *vi;
 
struct iq_desc *iq_desc;
@@ -694,20 +696,23 @@ struct sge_nm_rxq {
uint16_t iq_cidx;
uint16_t iq_sidx;
uint8_t iq_gen;
+   uint32_t fl_sidx;
 
-   __be64  *fl_desc;
+   /* Items used by netmap rxsync are in this cacheline. */
+   __be64  *fl_desc __aligned(CACHE_LINE_SIZE);
uint16_t fl_cntxt_id;
-   uint32_t fl_cidx;
uint32_t fl_pidx;
-   uint32_t fl_sidx;
+   uint32_t fl_sidx2;  /* copy of fl_sidx */
uint32_t fl_db_val;
+   u_int fl_db_saved;
u_int fl_hwidx:4;
 
-   u_int fl_db_saved;
-   u_int nid;  /* netmap ring # for this queue */
+   /*
+* fl_cidx is used by both the ithread and rxsync, the rest are not used
+* in the rx fast path.
+*/
+   uint32_t fl_cidx __aligned(CACHE_LINE_SIZE);
 
-   /* infrequently used items after this */
-
bus_dma_tag_t iq_desc_tag;
bus_dmamap_t iq_desc_map;
bus_addr_t iq_ba;
@@ -716,7 +721,7 @@ struct sge_nm_rxq {
bus_dma_tag_t fl_desc_tag;
bus_dmamap_t fl_desc_map;
bus_addr_t fl_ba;
-} __aligned(CACHE_LINE_SIZE);
+};
 
 #define INVALID_NM_TXQ_CNTXT_ID ((u_int)(-1))
 struct sge_nm_txq {

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Fri Mar 20 04:13:39 2020
(r359158)
+++ head/sys/dev/cxgbe/t4_netmap.c  Fri Mar 20 05:12:16 2020
(r359159)
@@ -921,7 +921,7 @@ cxgbe_netmap_rxsync(struct netmap_kring *kring, int fl
MPASS((n & 7) == 0);
 
IDXINCR(kring->nr_hwcur, n, kring->nkr_num_slots);
-   IDXINCR(nm_rxq->fl_pidx, n, nm_rxq->fl_sidx);
+   IDXINCR(nm_rxq->fl_pidx, n, nm_rxq->fl_sidx2);
 
while (n > 0) {
for (i = 0; i < 8; i++, fl_pidx++, slot++) {
@@ -929,10 +929,10 @@ cxgbe_netmap_rxsync(struct netmap_kring *kring, int fl
MPASS(ba != 0);
nm_rxq->fl_desc[fl_pidx] = htobe64(ba | hwidx);
slot->flags &= ~NS_BUF_CHANGED;
-   MPASS(fl_pidx <= nm_rxq->fl_sidx);
+   MPASS(fl_pidx <= nm_rxq->fl_sidx2);
}
n -= 8;
-   if (fl_pidx == nm_rxq->fl_sidx) {
+   if (fl_pidx == nm_rxq->fl_sidx2) {
fl_pidx = 0;
slot = >slot[0];
}

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Fri Mar 20 04:13:39 2020(r359158)
+++ head/sys/dev/cxgbe/t4_sge.c Fri Mar 20 05:12:16 2020(r359159)
@@ -3655,6 +3655,7 @@ alloc_nm_rxq(struct vi_info *vi, struct sge_nm_rxq *nm
nm_rxq->iq_gen = F_RSPD_GEN;
nm_rxq->fl_pidx = nm_rxq->fl_cidx = 0;
nm_rxq->fl_sidx = na->num_rx_desc;
+   nm_rxq->fl_sidx2 = nm_rxq->fl_sidx; /* copy for rxsync cacheline */
nm_rxq->intr_idx = intr_idx;
nm_rxq->iq_cntxt_id = INVALID_NM_RXQ_CNTXT_ID;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r359057 - head/sys/dev/pci

2020-03-17 Thread Navdeep Parhar
Author: np
Date: Wed Mar 18 01:09:40 2020
New Revision: 359057
URL: https://svnweb.freebsd.org/changeset/base/359057

Log:
  Remove spurious warning about invalid VPD data.
  
  The warning used to be displayed for valid VPDs about 512B or above in
  size.  Fix the size check and add a break while here so that the routine
  stops if if detects any problem.
  
  Tested with "pciconf -lV"
  
  Reviewed by:  kib@, jhb@
  MFC after:1 week
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D23679

Modified:
  head/sys/dev/pci/pci.c

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Tue Mar 17 23:58:58 2020(r359056)
+++ head/sys/dev/pci/pci.c  Wed Mar 18 01:09:40 2020(r359057)
@@ -1102,16 +1102,16 @@ pci_read_vpd(device_t pcib, pcicfgregs *cfg)
break;
}
remain |= byte2 << 8;
-   if (remain > (0x7f*4 - vrs.off)) {
-   state = -1;
-   pci_printf(cfg,
-   "invalid VPD data, remain %#x\n",
-   remain);
-   }
name = byte & 0x7f;
} else {
remain = byte & 0x7;
name = (byte >> 3) & 0xf;
+   }
+   if (vrs.off + remain - vrs.bytesinval > 0x8000) {
+   pci_printf(cfg,
+   "VPD data overflow, remain %#x\n", remain);
+   state = -1;
+   break;
}
switch (name) {
case 0x2:   /* String */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r358986 - stable/12/sys/dev/cxgbe/tom

2020-03-13 Thread Navdeep Parhar
Author: np
Date: Sat Mar 14 02:24:11 2020
New Revision: 358986
URL: https://svnweb.freebsd.org/changeset/base/358986

Log:
  MFC r358717:
  
  cxgbe/t4_tom: Do not uninitialize a toepcb that has not been initialized.
  
  This fixes the following panic:
  --- trap 0xc, rip = 0x80c00411, rsp = 0xfe0025192840, rbp = 
0xfe0025192860 ---
  vmem_xfree() at vmem_xfree+0xd1/frame 0xfe0025192860
  tls_uninit_toep() at tls_uninit_toep+0x78/frame 0xfe0025192880
  free_toepcb() at free_toepcb+0x32/frame 0xfe00251928a0
  t4_connect() at t4_connect+0x3be/frame 0xfe0025192950
  tcp_offload_connect() at tcp_offload_connect+0xa4/frame 0xfe0025192990
  tcp_usr_connect() at tcp_usr_connect+0xec/frame 0xfe00251929f0
  soconnect() at soconnect+0xae/frame 0xfe0025192a30
  kern_connectat() at kern_connectat+0xe2/frame 0xfe0025192a90
  sys_connect() at sys_connect+0x75/frame 0xfe0025192ad0
  amd64_syscall() at amd64_syscall+0x137/frame 0xfe0025192bf0
  fast_syscall_common() at fast_syscall_common+0x101/frame 0xfe0025192bf0
  --- syscall (98, FreeBSD ELF64, sys_connect), rip = 0x8008e9d8a, rsp = 
0x7fffc0f8, rbp = 0x7fffc130 ---
  
  Reviewed by:  jhb@
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D23989

Modified:
  stable/12/sys/dev/cxgbe/tom/t4_tom.c
  stable/12/sys/dev/cxgbe/tom/t4_tom.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/tom/t4_tom.c
==
--- stable/12/sys/dev/cxgbe/tom/t4_tom.cSat Mar 14 02:20:53 2020
(r358985)
+++ stable/12/sys/dev/cxgbe/tom/t4_tom.cSat Mar 14 02:24:11 2020
(r358986)
@@ -186,6 +186,8 @@ init_toepcb(struct vi_info *vi, struct toepcb *toep)
if (ulp_mode(toep) == ULP_MODE_TCPDDP)
ddp_init_toep(toep);
 
+   toep->flags |= TPF_INITIALIZED;
+
return (0);
 }
 
@@ -209,9 +211,11 @@ free_toepcb(struct toepcb *toep)
KASSERT(!(toep->flags & TPF_CPL_PENDING),
("%s: CPL pending", __func__));
 
-   if (ulp_mode(toep) == ULP_MODE_TCPDDP)
-   ddp_uninit_toep(toep);
-   tls_uninit_toep(toep);
+   if (toep->flags & TPF_INITIALIZED) {
+   if (ulp_mode(toep) == ULP_MODE_TCPDDP)
+   ddp_uninit_toep(toep);
+   tls_uninit_toep(toep);
+   }
free(toep, M_CXGBE);
 }
 

Modified: stable/12/sys/dev/cxgbe/tom/t4_tom.h
==
--- stable/12/sys/dev/cxgbe/tom/t4_tom.hSat Mar 14 02:20:53 2020
(r358985)
+++ stable/12/sys/dev/cxgbe/tom/t4_tom.hSat Mar 14 02:24:11 2020
(r358986)
@@ -72,6 +72,7 @@ enum {
TPF_SYNQE  = (1 << 8),  /* synq_entry, not really a toepcb */
TPF_SYNQE_EXPANDED = (1 << 9),  /* toepcb ready, tid context updated */
TPF_FORCE_CREDITS  = (1 << 10), /* always send credits */
+   TPF_INITIALIZED= (1 << 12), /* init_toepcb has been called */
 };
 
 enum {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


  1   2   3   4   5   6   7   8   9   10   >