git: 0a3ca84be17d - stable/13 - cxgbe(4): Fix "set but not used [-Wunused-but-set-variable]" warnings.

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Wed, 02 Mar 2022 21:45:54 UTC
The branch stable/13 has been updated by np:

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

commit 0a3ca84be17d0d7980d79b92d2cca1305594354e
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2022-01-05 20:23:06 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2022-03-02 21:25:55 +0000

    cxgbe(4): Fix "set but not used [-Wunused-but-set-variable]" warnings.
    
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit 39d5cbdc1b783e2f199349a7a20b6d7c58e180a0)
---
 sys/dev/cxgbe/common/t4_hw.c      |  4 ----
 sys/dev/cxgbe/cudbg/cudbg_lib.c   |  4 +---
 sys/dev/cxgbe/cudbg/fastlz_api.c  |  5 -----
 sys/dev/cxgbe/cxgbei/cxgbei.c     |  7 ++++---
 sys/dev/cxgbe/cxgbei/icl_cxgbei.c |  8 ++++++--
 sys/dev/cxgbe/iw_cxgbe/cm.c       | 10 ++++++++++
 sys/dev/cxgbe/t4_main.c           |  3 ---
 sys/dev/cxgbe/t4_sge.c            | 24 ++++++++++++++++--------
 sys/dev/cxgbe/tom/t4_connect.c    | 11 +++++++++++
 sys/dev/cxgbe/tom/t4_ddp.c        | 20 ++++++++++++++++++--
 sys/dev/cxgbe/tom/t4_tls.c        |  7 ++++++-
 11 files changed, 72 insertions(+), 31 deletions(-)

diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c
index 6191cf5533cd..c7e4d48e855f 100644
--- a/sys/dev/cxgbe/common/t4_hw.c
+++ b/sys/dev/cxgbe/common/t4_hw.c
@@ -6649,7 +6649,6 @@ int t4_set_trace_filter(struct adapter *adap, const struct trace_params *tp,
 {
 	int i, ofst = idx * 4;
 	u32 data_reg, mask_reg, cfg;
-	u32 multitrc = F_TRCMULTIFILTER;
 	u32 en = is_t4(adap) ? F_TFEN : F_T5_TFEN;
 
 	if (idx < 0 || idx >= NTRACE)
@@ -6684,7 +6683,6 @@ int t4_set_trace_filter(struct adapter *adap, const struct trace_params *tp,
 		 * maximum packet capture size of 9600 bytes is recommended.
 		 * Also in this mode, only trace0 can be enabled and running.
 		 */
-		multitrc = 0;
 		if (tp->snap_len > 9600 || idx)
 			return -EINVAL;
 	}
@@ -9077,7 +9075,6 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
 		int i;
 		int chan = G_FW_PORT_CMD_PORTID(be32_to_cpu(p->op_to_portid));
 		struct port_info *pi = NULL;
-		struct link_config *lc;
 
 		for_each_port(adap, i) {
 			pi = adap2pinfo(adap, i);
@@ -9085,7 +9082,6 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
 				break;
 		}
 
-		lc = &pi->link_cfg;
 		PORT_LOCK(pi);
 		handle_port_info(pi, p, action, &mod_changed, &link_changed);
 		PORT_UNLOCK(pi);
diff --git a/sys/dev/cxgbe/cudbg/cudbg_lib.c b/sys/dev/cxgbe/cudbg/cudbg_lib.c
index aeebd81e3350..dcbcb24807b9 100644
--- a/sys/dev/cxgbe/cudbg/cudbg_lib.c
+++ b/sys/dev/cxgbe/cudbg/cudbg_lib.c
@@ -2386,7 +2386,7 @@ static int collect_cim_qcfg(struct cudbg_init *pdbg_init,
 	struct cudbg_buffer scratch_buff;
 	struct adapter *padap = pdbg_init->adap;
 	u32 offset;
-	int cim_num_obq, rc = 0;
+	int rc = 0;
 
 	struct struct_cim_qcfg *cim_qcfg_data = NULL;
 
@@ -2398,8 +2398,6 @@ static int collect_cim_qcfg(struct cudbg_init *pdbg_init,
 
 	offset = scratch_buff.offset;
 
-	cim_num_obq = is_t4(padap) ? CIM_NUM_OBQ : CIM_NUM_OBQ_T5;
-
 	cim_qcfg_data =
 		(struct struct_cim_qcfg *)((u8 *)((char *)scratch_buff.data +
 					   offset));
diff --git a/sys/dev/cxgbe/cudbg/fastlz_api.c b/sys/dev/cxgbe/cudbg/fastlz_api.c
index 7a8131f6da3e..68739fbdbb10 100644
--- a/sys/dev/cxgbe/cudbg/fastlz_api.c
+++ b/sys/dev/cxgbe/cudbg/fastlz_api.c
@@ -349,7 +349,6 @@ int decompress_buffer(struct cudbg_buffer *pc_buff,
 	unsigned long chunk_checksum;
 	unsigned long chunk_extra;
 	unsigned long checksum;
-	unsigned long total_extracted = 0;
 	unsigned long r;
 	unsigned long remaining;
 	unsigned long bytes_read;
@@ -409,8 +408,6 @@ int decompress_buffer(struct cudbg_buffer *pc_buff,
 				pc_buff->offset -= chunk_size + 16;
 				return CUDBG_STATUS_SMALL_BUFF;
 			}
-			total_extracted = 0;
-
 		}
 
 		if (chunk_size > CUDBG_BLOCK_SIZE) {
@@ -438,7 +435,6 @@ int decompress_buffer(struct cudbg_buffer *pc_buff,
 			switch (chunk_options) {
 				/* stored, simply copy to output */
 			case 0:
-				total_extracted += chunk_size;
 				remaining = chunk_size;
 				checksum = 1L;
 				for (;;) {
@@ -485,7 +481,6 @@ int decompress_buffer(struct cudbg_buffer *pc_buff,
 
 				checksum = update_adler32(1L, compressed_buffer,
 							  chunk_size);
-				total_extracted += chunk_extra;
 
 				/* verify that the chunk data is correct */
 				if (checksum != chunk_checksum) {
diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.c b/sys/dev/cxgbe/cxgbei/cxgbei.c
index bd34e6a2a149..d6bf3ab871e8 100644
--- a/sys/dev/cxgbe/cxgbei/cxgbei.c
+++ b/sys/dev/cxgbe/cxgbei/cxgbei.c
@@ -488,6 +488,7 @@ do_rx_iscsi_cmp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 	struct inpcb *inp = toep->inp;
 #ifdef INVARIANTS
 	uint16_t len = be16toh(cpl->len);
+	u_int data_digest_len;
 #endif
 	struct socket *so;
 	struct sockbuf *sb;
@@ -496,7 +497,7 @@ do_rx_iscsi_cmp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 	struct icl_conn *ic;
 	struct iscsi_bhs_data_out *bhsdo;
 	u_int val = be32toh(cpl->ddpvld);
-	u_int npdus, pdu_len, data_digest_len, hdr_digest_len;
+	u_int npdus, pdu_len;
 	uint32_t prev_seg_len;
 
 	M_ASSERTPKTHDR(m);
@@ -598,11 +599,11 @@ do_rx_iscsi_cmp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 		return (0);
 	}
 
+#ifdef INVARIANTS
 	data_digest_len = (icc->ulp_submode & ULP_CRC_DATA) ?
 	    ISCSI_DATA_DIGEST_SIZE : 0;
-	hdr_digest_len = (icc->ulp_submode & ULP_CRC_HEADER) ?
-	    ISCSI_HEADER_DIGEST_SIZE : 0;
 	MPASS(roundup2(ip->ip_data_len, 4) == pdu_len - len - data_digest_len);
+#endif
 
 	if (val & F_DDP_PDU && ip->ip_data_mbuf == NULL) {
 		MPASS((icp->icp_flags & ICPF_RX_FLBUF) == 0);
diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
index de8f2547f29a..6ba3a70a543c 100644
--- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
+++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
@@ -784,7 +784,6 @@ int
 icl_cxgbei_conn_handoff(struct icl_conn *ic, int fd)
 {
 	struct icl_cxgbei_conn *icc = ic_to_icc(ic);
-	struct cxgbei_data *ci;
 	struct find_ofld_adapter_rr fa;
 	struct file *fp;
 	struct socket *so;
@@ -836,7 +835,6 @@ icl_cxgbei_conn_handoff(struct icl_conn *ic, int fd)
 	if (fa.sc == NULL)
 		return (EINVAL);
 	icc->sc = fa.sc;
-	ci = icc->sc->iscsi_ulp_softc;
 
 	max_rx_pdu_len = ISCSI_BHS_SIZE + ic->ic_max_recv_data_segment_length;
 	max_tx_pdu_len = ISCSI_BHS_SIZE + ic->ic_max_send_data_segment_length;
@@ -1180,19 +1178,25 @@ icl_cxgbei_conn_task_done(struct icl_conn *ic, void *arg)
 static inline bool
 ddp_sgl_check(struct ctl_sg_entry *sg, int entries, int xferlen)
 {
+#ifdef INVARIANTS
 	int total_len = 0;
+#endif
 
 	MPASS(entries > 0);
 	if (((vm_offset_t)sg[--entries].addr & 3U) != 0)
 		return (false);
 
+#ifdef INVARIANTS
 	total_len += sg[entries].len;
+#endif
 
 	while (--entries >= 0) {
 		if (((vm_offset_t)sg[entries].addr & PAGE_MASK) != 0 ||
 		    (sg[entries].len % PAGE_SIZE) != 0)
 			return (false);
+#ifdef INVARIANTS
 		total_len += sg[entries].len;
+#endif
 	}
 
 	MPASS(total_len == xferlen);
diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c
index b83622cc3c65..dfc2f7ac4f2c 100644
--- a/sys/dev/cxgbe/iw_cxgbe/cm.c
+++ b/sys/dev/cxgbe/iw_cxgbe/cm.c
@@ -1322,10 +1322,14 @@ alloc_ep(int size, gfp_t gfp)
 void _c4iw_free_ep(struct kref *kref)
 {
 	struct c4iw_ep *ep;
+#if defined(KTR) || defined(INVARIANTS)
 	struct c4iw_ep_common *epc;
+#endif
 
 	ep = container_of(kref, struct c4iw_ep, com.kref);
+#if defined(KTR) || defined(INVARIANTS)
 	epc = &ep->com;
+#endif
 	KASSERT(!epc->entry.tqe_prev, ("%s epc %p still on req list",
 	    __func__, epc));
 	if (test_bit(QP_REFERENCED, &ep->com.flags))
@@ -2352,7 +2356,9 @@ err_out:
  */
 int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
 {
+#ifdef KTR
 	int err;
+#endif
 	struct c4iw_ep *ep = to_ep(cm_id);
 	int abort = 0;
 
@@ -2380,7 +2386,11 @@ int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
 		abort = send_mpa_reject(ep, pdata, pdata_len);
 	}
 	STOP_EP_TIMER(ep);
+#ifdef KTR
 	err = c4iw_ep_disconnect(ep, abort != 0, GFP_KERNEL);
+#else
+	c4iw_ep_disconnect(ep, abort != 0, GFP_KERNEL);
+#endif
 	mutex_unlock(&ep->com.mutex);
 	c4iw_put_ep(&ep->com);
 	CTR3(KTR_IW_CXGBE, "%s:crc4 %p, err: %d", __func__, ep, err);
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 333373e69aea..b6045dd41674 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -1670,11 +1670,8 @@ notify_siblings(device_t dev, int detaching)
 static int
 t4_detach(device_t dev)
 {
-	struct adapter *sc;
 	int rc;
 
-	sc = device_get_softc(dev);
-
 	rc = notify_siblings(dev, 1);
 	if (rc) {
 		device_printf(dev,
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index cbfaa7a6db60..092d8e59b889 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -2677,10 +2677,13 @@ int
 parse_pkt(struct mbuf **mp, bool vm_wr)
 {
 	struct mbuf *m0 = *mp, *m;
-	int rc, nsegs, defragged = 0, offset;
+	int rc, nsegs, defragged = 0;
 	struct ether_header *eh;
+#ifdef INET
 	void *l3hdr;
+#endif
 #if defined(INET) || defined(INET6)
+	int offset;
 	struct tcphdr *tcp;
 #endif
 #if defined(KERN_TLS) || defined(RATELIMIT)
@@ -2788,8 +2791,14 @@ restart:
 	} else
 		m0->m_pkthdr.l2hlen = sizeof(*eh);
 
+#if defined(INET) || defined(INET6)
 	offset = 0;
+#ifdef INET
 	l3hdr = m_advance(&m, &offset, m0->m_pkthdr.l2hlen);
+#else
+	m_advance(&m, &offset, m0->m_pkthdr.l2hlen);
+#endif
+#endif
 
 	switch (eh_type) {
 #ifdef INET6
@@ -2829,6 +2838,7 @@ restart:
 		goto fail;
 	}
 
+#if defined(INET) || defined(INET6)
 	if (needs_vxlan_csum(m0)) {
 		m0->m_pkthdr.l4hlen = sizeof(struct udphdr);
 		m0->m_pkthdr.l5hlen = sizeof(struct vxlan_header);
@@ -2844,7 +2854,11 @@ restart:
 			m0->m_pkthdr.inner_l2hlen = sizeof(*evh);
 		} else
 			m0->m_pkthdr.inner_l2hlen = sizeof(*eh);
+#ifdef INET
 		l3hdr = m_advance(&m, &offset, m0->m_pkthdr.inner_l2hlen);
+#else
+		m_advance(&m, &offset, m0->m_pkthdr.inner_l2hlen);
+#endif
 
 		switch (eh_type) {
 #ifdef INET6
@@ -2872,12 +2886,10 @@ restart:
 			rc = EINVAL;
 			goto fail;
 		}
-#if defined(INET) || defined(INET6)
 		if (needs_inner_tcp_csum(m0)) {
 			tcp = m_advance(&m, &offset, m0->m_pkthdr.inner_l3hlen);
 			m0->m_pkthdr.inner_l4hlen = tcp->th_off * 4;
 		}
-#endif
 		MPASS((m0->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0);
 		m0->m_pkthdr.csum_flags &= CSUM_INNER_IP6_UDP |
 		    CSUM_INNER_IP6_TCP | CSUM_INNER_IP6_TSO | CSUM_INNER_IP |
@@ -2885,7 +2897,6 @@ restart:
 		    CSUM_ENCAP_VXLAN;
 	}
 
-#if defined(INET) || defined(INET6)
 	if (needs_outer_tcp_csum(m0)) {
 		tcp = m_advance(&m, &offset, m0->m_pkthdr.l3hlen);
 		m0->m_pkthdr.l4hlen = tcp->th_off * 4;
@@ -5382,14 +5393,13 @@ write_txpkt_vm_wr(struct adapter *sc, struct sge_txq *txq, struct mbuf *m0)
 	struct cpl_tx_pkt_core *cpl;
 	uint32_t ctrl;	/* used in many unrelated places */
 	uint64_t ctrl1;
-	int len16, ndesc, pktlen, nsegs;
+	int len16, ndesc, pktlen;
 	caddr_t dst;
 
 	TXQ_LOCK_ASSERT_OWNED(txq);
 	M_ASSERTPKTHDR(m0);
 
 	len16 = mbuf_len16(m0);
-	nsegs = mbuf_nsegs(m0);
 	pktlen = m0->m_pkthdr.len;
 	ctrl = sizeof(struct cpl_tx_pkt_core);
 	if (needs_tso(m0))
@@ -6564,7 +6574,6 @@ write_ethofld_wr(struct cxgbe_rate_tag *cst, struct fw_eth_tx_eo_wr *wr,
 	uint64_t ctrl1;
 	uint32_t ctrl;	/* used in many unrelated places */
 	int len16, pktlen, nsegs, immhdrs;
-	caddr_t dst;
 	uintptr_t p;
 	struct ulptx_sgl *usgl;
 	struct sglist sg;
@@ -6659,7 +6668,6 @@ write_ethofld_wr(struct cxgbe_rate_tag *cst, struct fw_eth_tx_eo_wr *wr,
 	m_copydata(m0, 0, immhdrs, (void *)p);
 
 	/* SGL */
-	dst = (void *)(cpl + 1);
 	if (nsegs > 0) {
 		int i, pad;
 
diff --git a/sys/dev/cxgbe/tom/t4_connect.c b/sys/dev/cxgbe/tom/t4_connect.c
index f4aa84d6514f..2ba27d62686f 100644
--- a/sys/dev/cxgbe/tom/t4_connect.c
+++ b/sys/dev/cxgbe/tom/t4_connect.c
@@ -182,11 +182,18 @@ t4_uninit_connect_cpl_handlers(void)
 	t4_register_shared_cpl_handler(CPL_ACT_OPEN_RPL, NULL, CPL_COOKIE_TOM);
 }
 
+#ifdef KTR
 #define DONT_OFFLOAD_ACTIVE_OPEN(x)	do { \
 	reason = __LINE__; \
 	rc = (x); \
 	goto failed; \
 } while (0)
+#else
+#define DONT_OFFLOAD_ACTIVE_OPEN(x)	do { \
+	rc = (x); \
+	goto failed; \
+} while (0)
+#endif
 
 static inline int
 act_open_cpl_size(struct adapter *sc, int isipv6)
@@ -235,7 +242,9 @@ t4_connect(struct toedev *tod, struct socket *so, struct nhop_object *nh,
 	int qid_atid, rc, isipv6;
 	struct inpcb *inp = sotoinpcb(so);
 	struct tcpcb *tp = intotcpcb(inp);
+#ifdef KTR
 	int reason;
+#endif
 	struct offload_settings settings;
 	struct epoch_tracker et;
 	uint16_t vid = 0xfff, pcp = 0;
@@ -381,7 +390,9 @@ t4_connect(struct toedev *tod, struct socket *so, struct nhop_object *nh,
 	}
 
 	undo_offload_socket(so);
+#if defined(KTR)
 	reason = __LINE__;
+#endif
 failed:
 	CTR3(KTR_CXGBE, "%s: not offloading (%d), rc %d", __func__, reason, rc);
 
diff --git a/sys/dev/cxgbe/tom/t4_ddp.c b/sys/dev/cxgbe/tom/t4_ddp.c
index be142ffb9e4f..f49a8aaaaf70 100644
--- a/sys/dev/cxgbe/tom/t4_ddp.c
+++ b/sys/dev/cxgbe/tom/t4_ddp.c
@@ -292,7 +292,10 @@ insert_ddp_data(struct toepcb *toep, uint32_t n)
 	struct kaiocb *job;
 	size_t placed;
 	long copied;
-	unsigned int db_flag, db_idx;
+	unsigned int db_idx;
+#ifdef INVARIANTS
+	unsigned int db_flag;
+#endif
 
 	INP_WLOCK_ASSERT(inp);
 	DDP_ASSERT_LOCKED(toep);
@@ -307,7 +310,9 @@ insert_ddp_data(struct toepcb *toep, uint32_t n)
 	while (toep->ddp.active_count > 0) {
 		MPASS(toep->ddp.active_id != -1);
 		db_idx = toep->ddp.active_id;
+#ifdef INVARIANTS
 		db_flag = db_idx == 1 ? DDP_BUF1_ACTIVE : DDP_BUF0_ACTIVE;
+#endif
 		MPASS((toep->ddp.flags & db_flag) != 0);
 		db = &toep->ddp.db[db_idx];
 		job = db->job;
@@ -694,7 +699,10 @@ handle_ddp_close(struct toepcb *toep, struct tcpcb *tp, __be32 rcv_nxt)
 	struct ddp_buffer *db;
 	struct kaiocb *job;
 	long copied;
-	unsigned int db_flag, db_idx;
+	unsigned int db_idx;
+#ifdef INVARIANTS
+	unsigned int db_flag;
+#endif
 	int len, placed;
 
 	INP_WLOCK_ASSERT(toep->inp);
@@ -707,7 +715,9 @@ handle_ddp_close(struct toepcb *toep, struct tcpcb *tp, __be32 rcv_nxt)
 	while (toep->ddp.active_count > 0) {
 		MPASS(toep->ddp.active_id != -1);
 		db_idx = toep->ddp.active_id;
+#ifdef INVARIANTS
 		db_flag = db_idx == 1 ? DDP_BUF1_ACTIVE : DDP_BUF0_ACTIVE;
+#endif
 		MPASS((toep->ddp.flags & db_flag) != 0);
 		db = &toep->ddp.db[db_idx];
 		job = db->job;
@@ -1798,7 +1808,9 @@ sbcopy:
 	while (m != NULL && resid > 0) {
 		struct iovec iov[1];
 		struct uio uio;
+#ifdef INVARIANTS
 		int error;
+#endif
 
 		iov[0].iov_base = mtod(m, void *);
 		iov[0].iov_len = m->m_len;
@@ -1810,8 +1822,12 @@ sbcopy:
 		uio.uio_resid = iov[0].iov_len;
 		uio.uio_segflg = UIO_SYSSPACE;
 		uio.uio_rw = UIO_WRITE;
+#ifdef INVARIANTS
 		error = uiomove_fromphys(ps->pages, offset + copied,
 		    uio.uio_resid, &uio);
+#else
+		uiomove_fromphys(ps->pages, offset + copied, uio.uio_resid, &uio);
+#endif
 		MPASS(error == 0 && uio.uio_resid == 0);
 		copied += uio.uio_offset;
 		resid -= uio.uio_offset;
diff --git a/sys/dev/cxgbe/tom/t4_tls.c b/sys/dev/cxgbe/tom/t4_tls.c
index bbd905d8acc3..fdd6d43c796b 100644
--- a/sys/dev/cxgbe/tom/t4_tls.c
+++ b/sys/dev/cxgbe/tom/t4_tls.c
@@ -2060,7 +2060,10 @@ do_rx_tls_cmp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 	struct tls_get_record *tgr;
 	struct mbuf *control;
 #endif
-	int len, pdu_length, rx_credits;
+	int pdu_length, rx_credits;
+#if defined(KTR) || defined(INVARIANTS)
+	int len;
+#endif
 
 	KASSERT(toep->tid == tid, ("%s: toep tid/atid mismatch", __func__));
 	KASSERT(!(toep->flags & TPF_SYNQE),
@@ -2068,7 +2071,9 @@ do_rx_tls_cmp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 
 	/* strip off CPL header */
 	m_adj(m, sizeof(*cpl));
+#if defined(KTR) || defined(INVARIANTS)
 	len = m->m_pkthdr.len;
+#endif
 
 	toep->ofld_rxq->rx_toe_tls_records++;