From nobody Thu Feb 2 07:39:38 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P6rK72mJNz3c98H; Thu, 2 Feb 2023 07:39:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P6rK726R2z3CR1; Thu, 2 Feb 2023 07:39:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675323579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vB8injebYOeQbUswKj6XFHhdXAZfE4pUXgkC/Lrw+94=; b=fzUk6lZ1elykflQzR/qmFI0RS+3ylkIxFpU1Gl2w3RfvIJdjwy+736wlZ+u/ii1zP8amIO OouA5kWnGkflPgi/XVcrm/t/a51QMMlbi4SqymlexEBZJjyk7X2pm/3dnNNm1zSYhV5W+/ CBL/JIQQic7t7Fhc+ZzfBijUcSHHNU2qG89SkUbYE7e0sBzNINM1nsMIuQaiuwY0dmR5TD pR1oyb0NX5SCYn5Lc3HXX4x9KGH1Le76ZSdaGoxZS2AbmHBv8nXCjoxeYHhvj49evhEIVO bUP+ejOoSFhfCA1ImlsrdSCEtE0JFVFhHFVxYYYpfqSaiuVLfuVGDFs+qyG8dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675323579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vB8injebYOeQbUswKj6XFHhdXAZfE4pUXgkC/Lrw+94=; b=dlpv3fnprcyRJNB7lt4UmoY+p3DBCPbR/laEm2uCSlbDVzl3oKaTZHadH6UoTT950skn6j aG5ZQcCULhAF8Dyfwyp325NbaTHM8HckP4VJW/PGZ5ehkhl7e/lQ8QguRIJ6tya7SQfPdN wyyEhg2n1abrEzxisQeEEaf4rjRJh3NtS2NjBxhE1CrL91cJBGNYachv/lP+frQYbEj0bh PdIKTTs06fZcMUfrOxm7E04B1RpS5bXbO1uPUm13N9MPxMmnl0nGMP71gCMScxDJ4ABdrI Wm2NwHfxhCKWwzU8C+T8TmjT3FDwu4V/OIQmcyfXYAo8O1Ja2CE10lTMOj+wuQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675323579; a=rsa-sha256; cv=none; b=qn/Fo+qmAq0AQPD0Z+QtXCVHuAJBIXzYQDyxYDSnFJz8kuzNEqGYf0XRm9wQrgMabWGxgM XD9GSo6XoBNlhakAkw4IqMih5wbXdO70JCKPyXmVyLsm0+Am7L3ZLnCTEbptRlfZO42egF Q/Q4Mi7dgnUttSW5ATcpzaTwaxUZIH1mwrtl2CByW99pI9qz8oJ3qyrjy6m27js2jy8CGv rNSGGx9iaE9hork6LKS9m7LVECLmuQ447iLvFF0k8E1KOcfsGyrolDakfNBqQF6b+5wiOD EOpphMPvaViemOkRAUHS46vb6SFVQ7EbkDr9mNhiydCUJ0ckj+GVLwL9cn/Gdg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P6rK70X02zmVL; Thu, 2 Feb 2023 07:39:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 3127dcZh062189; Thu, 2 Feb 2023 07:39:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3127dcvx062188; Thu, 2 Feb 2023 07:39:38 GMT (envelope-from git) Date: Thu, 2 Feb 2023 07:39:38 GMT Message-Id: <202302020739.3127dcvx062188@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 5adfcaeacafa - stable/13 - cxgbe(4): Add another setting to the knob that controls congestion. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5adfcaeacafa73522cf98403428e7785a7aecc82 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=5adfcaeacafa73522cf98403428e7785a7aecc82 commit 5adfcaeacafa73522cf98403428e7785a7aecc82 Author: Navdeep Parhar AuthorDate: 2022-09-09 22:16:22 +0000 Commit: Navdeep Parhar CommitDate: 2023-02-02 07:18:51 +0000 cxgbe(4): Add another setting to the knob that controls congestion. hw.cxgbe.cong_drop=2 will generate backpressure *and* drop frames for queues that are congested. Sponsored by: Chelsio Communications (cherry picked from commit df275ae5090048fb7a8c082d509fae57e891957a) --- share/man/man4/cxgbe.4 | 3 +- sys/dev/cxgbe/adapter.h | 4 +- sys/dev/cxgbe/t4_netmap.c | 41 ++++++------------ sys/dev/cxgbe/t4_sge.c | 106 +++++++++++++++++++++++++++++----------------- 4 files changed, 84 insertions(+), 70 deletions(-) diff --git a/share/man/man4/cxgbe.4 b/share/man/man4/cxgbe.4 index 5f959299d2ad..b0f8af93b3b6 100644 --- a/share/man/man4/cxgbe.4 +++ b/share/man/man4/cxgbe.4 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 10, 2021 +.Dd September 12, 2022 .Dt CXGBE 4 .Os .Sh NAME @@ -277,6 +277,7 @@ Controls the hardware response to congestion. 0 instructs the hardware to backpressure its pipeline on congestion. This usually results in the port emitting PAUSE frames. 1 instructs the hardware to drop frames destined for congested queues. +2 instructs the hardware to both backpressure the pipeline and drop frames. .It Va hw.cxgbe.pause_settings PAUSE frame settings. Bit 0 is rx_pause, bit 1 is tx_pause, bit 2 is pause_autoneg. diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index afb571323419..7de1913840a1 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -433,7 +433,7 @@ struct sge_iq { int8_t intr_pktc_idx; /* packet count threshold index */ uint8_t gen; /* generation bit */ uint8_t intr_params; /* interrupt holdoff parameters */ - int8_t cong; /* congestion settings */ + int8_t cong_drop; /* congestion drop settings for the queue */ uint16_t qsize; /* size (# of entries) of the queue */ uint16_t sidx; /* index of the entry with the status page */ uint16_t cidx; /* consumer index */ @@ -1403,7 +1403,7 @@ struct mbuf *alloc_wr_mbuf(int, int); 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); +int t4_sge_set_conm_context(struct adapter *, int, int, int); void t4_register_an_handler(an_handler_t); void t4_register_fw_msg_handler(int, fw_msg_handler_t); void t4_register_cpl_handler(int, cpl_handler_t); diff --git a/sys/dev/cxgbe/t4_netmap.c b/sys/dev/cxgbe/t4_netmap.c index 1ac24e75e733..06c9c98136f5 100644 --- a/sys/dev/cxgbe/t4_netmap.c +++ b/sys/dev/cxgbe/t4_netmap.c @@ -276,14 +276,17 @@ free_nm_txq(struct vi_info *vi, struct sge_nm_txq *nm_txq) } static int -alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int cong) +alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq) { - int rc, cntxt_id, i; + int rc, cntxt_id; __be32 v; struct adapter *sc = vi->adapter; + struct port_info *pi = vi->pi; struct sge_params *sp = &sc->params.sge; struct netmap_adapter *na = NA(vi->ifp); struct fw_iq_cmd c; + const int cong_drop = nm_cong_drop; + const int cong_map = pi->rx_e_chan_map; MPASS(na != NULL); MPASS(nm_rxq->iq_desc != NULL); @@ -313,15 +316,15 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int cong) V_FW_IQ_CMD_TYPE(FW_IQ_TYPE_FL_INT_CAP) | V_FW_IQ_CMD_VIID(vi->viid) | V_FW_IQ_CMD_IQANUD(X_UPDATEDELIVERY_INTERRUPT)); - c.iqdroprss_to_iqesize = htobe16(V_FW_IQ_CMD_IQPCIECH(vi->pi->tx_chan) | + c.iqdroprss_to_iqesize = htobe16(V_FW_IQ_CMD_IQPCIECH(pi->tx_chan) | F_FW_IQ_CMD_IQGTSMODE | V_FW_IQ_CMD_IQINTCNTTHRESH(0) | V_FW_IQ_CMD_IQESIZE(ilog2(IQ_ESIZE) - 4)); c.iqsize = htobe16(vi->qsize_rxq); c.iqaddr = htobe64(nm_rxq->iq_ba); - if (cong >= 0) { + if (cong_drop != -1) { c.iqns_to_fl0congen = htobe32(F_FW_IQ_CMD_IQFLINTCONGEN | - V_FW_IQ_CMD_FL0CNGCHMAP(cong) | F_FW_IQ_CMD_FL0CONGCIF | + V_FW_IQ_CMD_FL0CNGCHMAP(cong_map) | F_FW_IQ_CMD_FL0CONGCIF | F_FW_IQ_CMD_FL0CONGEN); } c.iqns_to_fl0congen |= @@ -373,29 +376,9 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int cong) nm_rxq->fl_db_val = V_QID(nm_rxq->fl_cntxt_id) | sc->chip_params->sge_fl_db; - if (chip_id(sc) >= CHELSIO_T5 && cong >= 0) { - uint32_t param, val; - - 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 { - val = 2 << 19; - for (i = 0; i < 4; i++) { - if (cong & (1 << i)) - val |= 1 << (i << 2); - } - } - - rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, ¶m, &val); - if (rc != 0) { - /* report error but carry on */ - device_printf(sc->dev, - "failed to set congestion manager context for " - "ingress queue %d: %d\n", nm_rxq->iq_cntxt_id, rc); - } + if (chip_id(sc) >= CHELSIO_T5 && cong_drop != -1) { + t4_sge_set_conm_context(sc, nm_rxq->iq_cntxt_id, cong_drop, + cong_map); } t4_write_reg(sc, sc->sge_gts_reg, @@ -749,7 +732,7 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, if (!nm_kring_pending_on(kring)) continue; - alloc_nm_rxq_hwq(vi, nm_rxq, tnl_cong(vi->pi, nm_cong_drop)); + alloc_nm_rxq_hwq(vi, nm_rxq); nm_rxq->fl_hwidx = hwidx; slot = netmap_reset(na, NR_RX, i, 0); MPASS(slot != NULL); /* XXXNM: error check, not assert */ diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index e485ca8736a7..8d83567c2725 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -123,10 +123,11 @@ SYSCTL_INT(_hw_cxgbe, OID_AUTO, spg_len, CTLFLAG_RDTUN, &spg_len, 0, * -1: no congestion feedback (not recommended). * 0: backpressure the channel instead of dropping packets right away. * 1: no backpressure, drop packets for the congested queue immediately. + * 2: both backpressure and drop. */ static int cong_drop = 0; SYSCTL_INT(_hw_cxgbe, OID_AUTO, cong_drop, CTLFLAG_RDTUN, &cong_drop, 0, - "Congestion control for RX queues (0 = backpressure, 1 = drop"); + "Congestion control for NIC RX queues (0 = backpressure, 1 = drop, 2 = both"); /* * Deliver multiple frames in the same free list buffer if they fit. @@ -553,7 +554,7 @@ t4_sge_modload(void) spg_len = len; } - if (cong_drop < -1 || cong_drop > 1) { + if (cong_drop < -1 || cong_drop > 2) { printf("Invalid hw.cxgbe.cong_drop value (%d)," " using 0 instead.\n", cong_drop); cong_drop = 0; @@ -3412,7 +3413,7 @@ init_iq(struct sge_iq *iq, struct adapter *sc, int tmr_idx, int pktc_idx, iq->qsize = roundup2(qsize, 16); /* See FW_IQ_CMD/iqsize */ iq->sidx = iq->qsize - sc->params.sge.spg_len / IQ_ESIZE; iq->intr_idx = intr_idx; - iq->cong = cong; + iq->cong_drop = cong; } static inline void @@ -3578,9 +3579,10 @@ free_iq_fl(struct adapter *sc, struct sge_iq *iq, struct sge_fl *fl) static int alloc_iq_fl_hwq(struct vi_info *vi, struct sge_iq *iq, struct sge_fl *fl) { - int rc, i, cntxt_id; + int rc, cntxt_id, cong_map; struct fw_iq_cmd c; struct adapter *sc = vi->adapter; + struct port_info *pi = vi->pi; __be32 v = 0; MPASS (!(iq->flags & IQ_HW_ALLOCATED)); @@ -3612,15 +3614,17 @@ alloc_iq_fl_hwq(struct vi_info *vi, struct sge_iq *iq, struct sge_fl *fl) V_FW_IQ_CMD_TYPE(FW_IQ_TYPE_FL_INT_CAP) | V_FW_IQ_CMD_VIID(vi->viid) | V_FW_IQ_CMD_IQANUD(X_UPDATEDELIVERY_INTERRUPT)); - c.iqdroprss_to_iqesize = htobe16(V_FW_IQ_CMD_IQPCIECH(vi->pi->tx_chan) | + c.iqdroprss_to_iqesize = htobe16(V_FW_IQ_CMD_IQPCIECH(pi->tx_chan) | F_FW_IQ_CMD_IQGTSMODE | V_FW_IQ_CMD_IQINTCNTTHRESH(iq->intr_pktc_idx) | V_FW_IQ_CMD_IQESIZE(ilog2(IQ_ESIZE) - 4)); c.iqsize = htobe16(iq->qsize); c.iqaddr = htobe64(iq->ba); c.iqns_to_fl0congen = htobe32(V_FW_IQ_CMD_IQTYPE(iq->qtype)); - if (iq->cong >= 0) + if (iq->cong_drop != -1) { + cong_map = iq->qtype == IQ_ETH ? pi->rx_e_chan_map : 0; c.iqns_to_fl0congen |= htobe32(F_FW_IQ_CMD_IQFLINTCONGEN); + } if (fl) { bzero(fl->desc, fl->sidx * EQ_ESIZE + sc->params.sge.spg_len); @@ -3630,9 +3634,9 @@ alloc_iq_fl_hwq(struct vi_info *vi, struct sge_iq *iq, struct sge_fl *fl) (fl_pad ? F_FW_IQ_CMD_FL0PADEN : 0) | (fl->flags & FL_BUF_PACKING ? F_FW_IQ_CMD_FL0PACKEN : 0)); - if (iq->cong >= 0) { + if (iq->cong_drop != -1) { c.iqns_to_fl0congen |= - htobe32(V_FW_IQ_CMD_FL0CNGCHMAP(iq->cong) | + htobe32(V_FW_IQ_CMD_FL0CNGCHMAP(cong_map) | F_FW_IQ_CMD_FL0CONGCIF | F_FW_IQ_CMD_FL0CONGEN); } @@ -3666,6 +3670,8 @@ alloc_iq_fl_hwq(struct vi_info *vi, struct sge_iq *iq, struct sge_fl *fl) if (fl) { u_int qid; #ifdef INVARIANTS + int i; + MPASS(!(fl->flags & FL_BUF_RESUME)); for (i = 0; i < fl->sidx * 8; i++) MPASS(fl->sdesc[i].cl == NULL); @@ -3705,28 +3711,10 @@ alloc_iq_fl_hwq(struct vi_info *vi, struct sge_iq *iq, struct sge_fl *fl) FL_UNLOCK(fl); } - if (chip_id(sc) >= CHELSIO_T5 && !(sc->flags & IS_VF) && iq->cong >= 0) { - uint32_t param, val; - - 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(iq->cntxt_id); - if (iq->cong == 0) - val = 1 << 19; - else { - val = 2 << 19; - for (i = 0; i < 4; i++) { - if (iq->cong & (1 << i)) - val |= 1 << (i << 2); - } - } - - rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, ¶m, &val); - if (rc != 0) { - /* report error but carry on */ - CH_ERR(sc, "failed to set congestion manager context " - "for ingress queue %d: %d\n", iq->cntxt_id, rc); - } + if (chip_id(sc) >= CHELSIO_T5 && !(sc->flags & IS_VF) && + iq->cong_drop != -1) { + t4_sge_set_conm_context(sc, iq->cntxt_id, iq->cong_drop, + cong_map); } /* Enable IQ interrupts */ @@ -3950,15 +3938,57 @@ free_ctrlq(struct adapter *sc, int idx) } int -tnl_cong(struct port_info *pi, int drop) +t4_sge_set_conm_context(struct adapter *sc, int cntxt_id, int cong_drop, + int cong_map) { + const int cng_ch_bits_log = sc->chip_params->cng_ch_bits_log; + uint32_t param, val; + uint16_t ch_map; + int cong_mode, rc, i; - if (drop == -1) - return (-1); - else if (drop == 1) - return (0); - else - return (pi->rx_e_chan_map); + if (chip_id(sc) < CHELSIO_T5) + return (ENOTSUP); + + /* Convert the driver knob to the mode understood by the firmware. */ + switch (cong_drop) { + case -1: + cong_mode = X_CONMCTXT_CNGTPMODE_DISABLE; + break; + case 0: + cong_mode = X_CONMCTXT_CNGTPMODE_CHANNEL; + break; + case 1: + cong_mode = X_CONMCTXT_CNGTPMODE_QUEUE; + break; + case 2: + cong_mode = X_CONMCTXT_CNGTPMODE_BOTH; + break; + default: + MPASS(0); + CH_ERR(sc, "cong_drop = %d is invalid (ingress queue %d).\n", + cong_drop, cntxt_id); + return (EINVAL); + } + + 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(cntxt_id); + val = V_CONMCTXT_CNGTPMODE(cong_mode); + if (cong_mode == X_CONMCTXT_CNGTPMODE_CHANNEL || + cong_mode == X_CONMCTXT_CNGTPMODE_BOTH) { + for (i = 0, ch_map = 0; i < 4; i++) { + if (cong_map & (1 << i)) + ch_map |= 1 << (i << cng_ch_bits_log); + } + val |= V_CONMCTXT_CNGCHMAP(ch_map); + } + rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, ¶m, &val); + if (rc != 0) { + CH_ERR(sc, "failed to set congestion manager context " + "for ingress queue %d: %d\n", cntxt_id, rc); + } + + return (rc); } /* @@ -3990,7 +4020,7 @@ alloc_rxq(struct vi_info *vi, struct sge_rxq *rxq, int idx, int intr_idx, "rx queue"); init_iq(&rxq->iq, sc, vi->tmr_idx, vi->pktc_idx, vi->qsize_rxq, - intr_idx, tnl_cong(vi->pi, cong_drop), IQ_ETH); + intr_idx, cong_drop, IQ_ETH); #if defined(INET) || defined(INET6) if (ifp->if_capenable & IFCAP_LRO) rxq->iq.flags |= IQ_LRO_ENABLED;