git: 6967516a2727 - stable/13 - qlxgb/qlxgbe/qlxge: Fix build without INET and/or without INET6.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 20 May 2022 00:35:17 UTC
The branch stable/13 has been updated by jhb:

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

commit 6967516a27275d3985d2ee9f8d3db5805438ddbb
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-04-22 22:18:05 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-20 00:22:07 +0000

    qlxgb/qlxgbe/qlxge: Fix build without INET and/or without INET6.
    
    This is in preparation for adding these drivers to amd64 NOTES.
    
    (cherry picked from commit 618aa8cd0ae0edca7d9a4e37ff242a6bb77bbccc)
---
 sys/dev/qlxgb/qla_hw.c  |  4 ++++
 sys/dev/qlxgb/qla_isr.c |  7 ++++++-
 sys/dev/qlxgb/qla_os.c  |  8 ++++++--
 sys/dev/qlxgb/qla_os.h  |  2 ++
 sys/dev/qlxgbe/ql_hw.c  |  6 ++++++
 sys/dev/qlxgbe/ql_isr.c |  9 ++++++++-
 sys/dev/qlxgbe/ql_os.c  |  8 ++++++--
 sys/dev/qlxgbe/ql_os.h  |  2 ++
 sys/dev/qlxge/qls_hw.c  | 10 ++++++++++
 sys/dev/qlxge/qls_isr.c | 16 +++++++++++++---
 sys/dev/qlxge/qls_os.c  | 12 ++++++++++--
 sys/dev/qlxge/qls_os.h  |  2 ++
 12 files changed, 75 insertions(+), 11 deletions(-)

diff --git a/sys/dev/qlxgb/qla_hw.c b/sys/dev/qlxgb/qla_hw.c
index 6144df147ee4..3936a7399435 100644
--- a/sys/dev/qlxgb/qla_hw.c
+++ b/sys/dev/qlxgb/qla_hw.c
@@ -1776,6 +1776,7 @@ qla_update_link_state(qla_host_t *ha)
 int
 qla_config_lro(qla_host_t *ha)
 {
+#if defined(INET) || defined(INET6)
 	int i;
         qla_hw_t *hw = &ha->hw;
 	struct lro_ctrl *lro;
@@ -1792,12 +1793,14 @@ qla_config_lro(qla_host_t *ha)
 	ha->flags.lro_init = 1;
 
 	QL_DPRINT2((ha->pci_dev, "%s: LRO initialized\n", __func__));
+#endif
 	return (0);
 }
 
 void
 qla_free_lro(qla_host_t *ha)
 {
+#if defined(INET) || defined(INET6)
 	int i;
         qla_hw_t *hw = &ha->hw;
 	struct lro_ctrl *lro;
@@ -1810,6 +1813,7 @@ qla_free_lro(qla_host_t *ha)
 		tcp_lro_free(lro);
 	}
 	ha->flags.lro_init = 0;
+#endif
 }
 
 void
diff --git a/sys/dev/qlxgb/qla_isr.c b/sys/dev/qlxgb/qla_isr.c
index 271baa886d1b..7966fc53b84f 100644
--- a/sys/dev/qlxgb/qla_isr.c
+++ b/sys/dev/qlxgb/qla_isr.c
@@ -139,9 +139,12 @@ qla_rx_intr(qla_host_t *ha, uint64_t data, uint32_t sds_idx,
 		mp->m_pkthdr.csum_flags = 0;
 	}
 
+#if defined(INET) || defined(INET6)
 	if (lro->lro_cnt && (tcp_lro_rx(lro, mp, 0) == 0)) {
 		/* LRO packet has been successfully queued */
-	} else {
+	} else
+#endif
+	{
 		(*ifp->if_input)(ifp, mp);
 	}
 
@@ -322,7 +325,9 @@ qla_rcv_isr(qla_host_t *ha, uint32_t sds_idx, uint32_t count)
 		}
 	}
 
+#if defined(INET) || defined(INET6)
 	tcp_lro_flush_all(lro);
+#endif
 
 	if (hw->sds[sds_idx].sdsr_next != comp_idx) {
 		QL_UPDATE_SDS_CONSUMER_INDEX(ha, sds_idx, comp_idx);
diff --git a/sys/dev/qlxgb/qla_os.c b/sys/dev/qlxgb/qla_os.c
index ab436867771e..9a8a02dfeb20 100644
--- a/sys/dev/qlxgb/qla_os.c
+++ b/sys/dev/qlxgb/qla_os.c
@@ -792,7 +792,9 @@ qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
 	int ret = 0;
 	struct ifreq *ifr = (struct ifreq *)data;
+#ifdef INET
 	struct ifaddr *ifa = (struct ifaddr *)data;
+#endif
 	qla_host_t *ha;
 
 	ha = (qla_host_t *)ifp->if_softc;
@@ -802,6 +804,7 @@ qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 		QL_DPRINT4((ha->pci_dev, "%s: SIOCSIFADDR (0x%lx)\n",
 			__func__, cmd));
 
+#ifdef INET
 		if (ifa->ifa_addr->sa_family == AF_INET) {
 			ifp->if_flags |= IFF_UP;
 			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
@@ -818,9 +821,10 @@ qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 				qla_config_ipv4_addr(ha,
 					(IA_SIN(ifa)->sin_addr.s_addr));
 			}
-		} else {
-			ether_ioctl(ifp, cmd, data);
+			break;
 		}
+#endif
+		ether_ioctl(ifp, cmd, data);
 		break;
 
 	case SIOCSIFMTU:
diff --git a/sys/dev/qlxgb/qla_os.h b/sys/dev/qlxgb/qla_os.h
index 1ee4f8d1ce61..fddae501b8b3 100644
--- a/sys/dev/qlxgb/qla_os.h
+++ b/sys/dev/qlxgb/qla_os.h
@@ -36,6 +36,8 @@
 #ifndef _QLA_OS_H_
 #define _QLA_OS_H_
 
+#include "opt_inet.h"
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/mbuf.h>
diff --git a/sys/dev/qlxgbe/ql_hw.c b/sys/dev/qlxgbe/ql_hw.c
index 9580a99c47b2..717089427d0a 100644
--- a/sys/dev/qlxgbe/ql_hw.c
+++ b/sys/dev/qlxgbe/ql_hw.c
@@ -2757,6 +2757,7 @@ qla_config_rss_ind_table(qla_host_t *ha)
 static int
 qla_config_soft_lro(qla_host_t *ha)
 {
+#if defined(INET) || defined(INET6)
         int i;
         qla_hw_t *hw = &ha->hw;
         struct lro_ctrl *lro;
@@ -2786,12 +2787,14 @@ qla_config_soft_lro(qla_host_t *ha)
         }
 
         QL_DPRINT2(ha, (ha->pci_dev, "%s: LRO initialized\n", __func__));
+#endif
         return (0);
 }
 
 static void
 qla_drain_soft_lro(qla_host_t *ha)
 {
+#if defined(INET) || defined(INET6)
         int i;
         qla_hw_t *hw = &ha->hw;
         struct lro_ctrl *lro;
@@ -2811,6 +2814,7 @@ qla_drain_soft_lro(qla_host_t *ha)
 		}
 #endif /* #if (__FreeBSD_version >= 1100101) */
 	}
+#endif
 
 	return;
 }
@@ -2818,6 +2822,7 @@ qla_drain_soft_lro(qla_host_t *ha)
 static void
 qla_free_soft_lro(qla_host_t *ha)
 {
+#if defined(INET) || defined(INET6)
         int i;
         qla_hw_t *hw = &ha->hw;
         struct lro_ctrl *lro;
@@ -2826,6 +2831,7 @@ qla_free_soft_lro(qla_host_t *ha)
                	lro = &hw->sds[i].lro;
 		tcp_lro_free(lro);
 	}
+#endif
 
 	return;
 }
diff --git a/sys/dev/qlxgbe/ql_isr.c b/sys/dev/qlxgbe/ql_isr.c
index c31d5369e0d6..0d1ae164c7ae 100644
--- a/sys/dev/qlxgbe/ql_isr.c
+++ b/sys/dev/qlxgbe/ql_isr.c
@@ -68,9 +68,11 @@ qla_rx_intr(qla_host_t *ha, qla_sgl_rcv_t *sgc, uint32_t sds_idx)
 	uint32_t		i, rem_len = 0;
 	uint32_t		r_idx = 0;
 	qla_rx_ring_t		*rx_ring;
+#if defined(INET) || defined(INET6)
 	struct lro_ctrl		*lro;
 
 	lro = &ha->hw.sds[sds_idx].lro;
+#endif
 
 	if (ha->hw.num_rds_rings > 1)
 		r_idx = sds_idx;
@@ -173,6 +175,7 @@ qla_rx_intr(qla_host_t *ha, qla_sgl_rcv_t *sgc, uint32_t sds_idx)
 #endif
 #endif /* #if __FreeBSD_version >= 1100000 */
 
+#if defined(INET) || defined(INET6)
 	if (ha->hw.enable_soft_lro) {
 #if (__FreeBSD_version >= 1100101)
 
@@ -184,7 +187,9 @@ qla_rx_intr(qla_host_t *ha, qla_sgl_rcv_t *sgc, uint32_t sds_idx)
 
 #endif /* #if (__FreeBSD_version >= 1100101) */
 
-	} else {
+	} else
+#endif
+	{
 		(*ifp->if_input)(ifp, mpf);
 	}
 
@@ -725,6 +730,7 @@ ql_rcv_isr(qla_host_t *ha, uint32_t sds_idx, uint32_t count)
 		}
 	}
 
+#if defined(INET) || defined(INET6)
 	if (ha->hw.enable_soft_lro) {
 		struct lro_ctrl		*lro;
 
@@ -745,6 +751,7 @@ ql_rcv_isr(qla_host_t *ha, uint32_t sds_idx, uint32_t count)
 
 #endif /* #if (__FreeBSD_version >= 1100101) */
 	}
+#endif
 
 	if (ha->stop_rcv)
 		goto ql_rcv_isr_exit;
diff --git a/sys/dev/qlxgbe/ql_os.c b/sys/dev/qlxgbe/ql_os.c
index 4edb6f0bb0dc..f83ae6022bd1 100644
--- a/sys/dev/qlxgbe/ql_os.c
+++ b/sys/dev/qlxgbe/ql_os.c
@@ -1024,7 +1024,9 @@ qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
 	int ret = 0;
 	struct ifreq *ifr = (struct ifreq *)data;
+#ifdef INET
 	struct ifaddr *ifa = (struct ifaddr *)data;
+#endif
 	qla_host_t *ha;
 
 	ha = (qla_host_t *)ifp->if_softc;
@@ -1036,6 +1038,7 @@ qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 		QL_DPRINT4(ha, (ha->pci_dev, "%s: SIOCSIFADDR (0x%lx)\n",
 			__func__, cmd));
 
+#ifdef INET
 		if (ifa->ifa_addr->sa_family == AF_INET) {
 			ret = QLA_LOCK(ha, __func__,
 					QLA_LOCK_DEFAULT_MS_TIMEOUT,
@@ -1060,9 +1063,10 @@ qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 				ntohl(IA_SIN(ifa)->sin_addr.s_addr)));
 
 			arp_ifinit(ifp, ifa);
-		} else {
-			ether_ioctl(ifp, cmd, data);
+			break;
 		}
+#endif
+		ether_ioctl(ifp, cmd, data);
 		break;
 
 	case SIOCSIFMTU:
diff --git a/sys/dev/qlxgbe/ql_os.h b/sys/dev/qlxgbe/ql_os.h
index f14c395d9663..fcee6e740828 100644
--- a/sys/dev/qlxgbe/ql_os.h
+++ b/sys/dev/qlxgbe/ql_os.h
@@ -36,6 +36,8 @@
 #ifndef _QL_OS_H_
 #define _QL_OS_H_
 
+#include "opt_inet.h"
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/mbuf.h>
diff --git a/sys/dev/qlxge/qls_hw.c b/sys/dev/qlxge/qls_hw.c
index a0a92e2f5d2a..ca97826c76dc 100644
--- a/sys/dev/qlxge/qls_hw.c
+++ b/sys/dev/qlxge/qls_hw.c
@@ -531,9 +531,12 @@ qls_init_fw_routing_table_exit:
 static int
 qls_tx_tso_chksum(qla_host_t *ha, struct mbuf *mp, q81_tx_tso_t *tx_mac)
 {
+#if defined(INET) || defined(INET6)
         struct ether_vlan_header *eh;
         struct ip *ip;
+#if defined(INET6)
         struct ip6_hdr *ip6;
+#endif
 	struct tcphdr *th;
         uint32_t ehdrlen, ip_hlen;
 	int ret = 0;
@@ -554,6 +557,7 @@ qls_tx_tso_chksum(qla_host_t *ha, struct mbuf *mp, q81_tx_tso_t *tx_mac)
         }
 
         switch (etype) {
+#ifdef INET
                 case ETHERTYPE_IP:
                         ip = (struct ip *)(mp->m_data + ehdrlen);
 
@@ -594,7 +598,9 @@ qls_tx_tso_chksum(qla_host_t *ha, struct mbuf *mp, q81_tx_tso_t *tx_mac)
 				tx_mac->flags |= Q81_TX_TSO_FLAGS_UC;
                         }
                 break;
+#endif
 
+#ifdef INET6
                 case ETHERTYPE_IPV6:
                         ip6 = (struct ip6_hdr *)(mp->m_data + ehdrlen);
 
@@ -620,6 +626,7 @@ qls_tx_tso_chksum(qla_host_t *ha, struct mbuf *mp, q81_tx_tso_t *tx_mac)
 				tx_mac->flags |= Q81_TX_TSO_FLAGS_UC;
                         }
                 break;
+#endif
 
                 default:
                         ret = -1;
@@ -627,6 +634,9 @@ qls_tx_tso_chksum(qla_host_t *ha, struct mbuf *mp, q81_tx_tso_t *tx_mac)
         }
 
         return (ret);
+#else
+	return (-1);
+#endif
 }
 
 #define QLA_TX_MIN_FREE 2
diff --git a/sys/dev/qlxge/qls_isr.c b/sys/dev/qlxge/qls_isr.c
index e77aab97c9a1..38da2d2c3408 100644
--- a/sys/dev/qlxge/qls_isr.c
+++ b/sys/dev/qlxge/qls_isr.c
@@ -130,12 +130,16 @@ qls_rx_comp(qla_host_t *ha, uint32_t rxr_idx, uint32_t cq_idx, q81_rx_t *cq_e)
 	device_t	dev = ha->pci_dev;
 	struct mbuf     *mp = NULL;
 	struct ifnet	*ifp = ha->ifp;
+#if defined(INET) || defined(INET6)
 	struct lro_ctrl	*lro;
+#endif
 	struct ether_vlan_header *eh;
 
 	rxr = &ha->rx_ring[rxr_idx];
 
+#if defined(INET) || defined(INET6)
 	lro = &rxr->lro;
+#endif
 
 	rxb = &rxr->rx_buf[rxr->rx_next];
 
@@ -200,9 +204,12 @@ qls_rx_comp(qla_host_t *ha, uint32_t rxr_idx, uint32_t cq_idx, q81_rx_t *cq_e)
 			}
 			if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
 
+#if defined(INET) || defined(INET6)
 			if (lro->lro_cnt && (tcp_lro_rx(lro, mp, 0) == 0)) {
 				/* LRO packet has been successfully queued */
-			} else {
+			} else
+#endif
+			{
 				(*ifp->if_input)(ifp, mp);
 			}
 		}
@@ -228,10 +235,11 @@ qls_cq_isr(qla_host_t *ha, uint32_t cq_idx)
 	q81_cq_e_t *cq_e, *cq_b;
 	uint32_t i, cq_comp_idx;
 	int ret = 0, tx_comp_done = 0;
-	struct lro_ctrl	*lro;
+#if defined(INET) || defined(INET6)
+	struct lro_ctrl	*lro = &ha->rx_ring[cq_idx].lro;
+#endif
 
 	cq_b = ha->rx_ring[cq_idx].cq_base_vaddr;
-	lro = &ha->rx_ring[cq_idx].lro;
 
 	cq_comp_idx = *(ha->rx_ring[cq_idx].cqi_vaddr);
 
@@ -281,7 +289,9 @@ qls_cq_isr(qla_host_t *ha, uint32_t cq_idx)
                 }
 	}
 
+#if defined(INET) || defined(INET6)
 	tcp_lro_flush_all(lro);
+#endif
 
 	ha->rx_ring[cq_idx].cq_next = cq_comp_idx;
 
diff --git a/sys/dev/qlxge/qls_os.c b/sys/dev/qlxge/qls_os.c
index a45e10da492d..3eca6f20f531 100644
--- a/sys/dev/qlxge/qls_os.c
+++ b/sys/dev/qlxge/qls_os.c
@@ -862,7 +862,9 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
 	int ret = 0;
 	struct ifreq *ifr = (struct ifreq *)data;
+#ifdef INET
 	struct ifaddr *ifa = (struct ifaddr *)data;
+#endif
 	qla_host_t *ha;
 
 	ha = (qla_host_t *)ifp->if_softc;
@@ -872,6 +874,7 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 		QL_DPRINT4((ha->pci_dev, "%s: SIOCSIFADDR (0x%lx)\n",
 			__func__, cmd));
 
+#ifdef INET
 		if (ifa->ifa_addr->sa_family == AF_INET) {
 			ifp->if_flags |= IFF_UP;
 			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
@@ -885,9 +888,10 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 				ntohl(IA_SIN(ifa)->sin_addr.s_addr)));
 
 			arp_ifinit(ifp, ifa);
-		} else {
-			ether_ioctl(ifp, cmd, data);
+			break;
 		}
+#endif
+		ether_ioctl(ifp, cmd, data);
 		break;
 
 	case SIOCSIFMTU:
@@ -1459,6 +1463,7 @@ qls_tx_done(void *context, int pending)
 static int
 qls_config_lro(qla_host_t *ha)
 {
+#if defined(INET) || defined(INET6)
         int i;
         struct lro_ctrl *lro;
 
@@ -1474,12 +1479,14 @@ qls_config_lro(qla_host_t *ha)
         ha->flags.lro_init = 1;
 
         QL_DPRINT2((ha->pci_dev, "%s: LRO initialized\n", __func__));
+#endif
         return (0);
 }
 
 static void
 qls_free_lro(qla_host_t *ha)
 {
+#if defined(INET) || defined(INET6)
         int i;
         struct lro_ctrl *lro;
 
@@ -1491,6 +1498,7 @@ qls_free_lro(qla_host_t *ha)
                 tcp_lro_free(lro);
         }
         ha->flags.lro_init = 0;
+#endif
 }
 
 static void
diff --git a/sys/dev/qlxge/qls_os.h b/sys/dev/qlxge/qls_os.h
index ac97575c8ffa..b10a37ecd5d3 100644
--- a/sys/dev/qlxge/qls_os.h
+++ b/sys/dev/qlxge/qls_os.h
@@ -36,6 +36,8 @@
 #ifndef _QLS_OS_H_
 #define _QLS_OS_H_
 
+#include "opt_inet.h"
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/mbuf.h>