Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Feb 2023 19:18:15 GMT
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 37d22ce08707 - main - Mechanically convert mana to IfAPI
Message-ID:  <202302071918.317JIF2r049890@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhibbits:

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

commit 37d22ce087076df172005d52a0f4877f1c4fba8b
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2022-08-19 16:06:32 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2023-02-07 19:16:18 +0000

    Mechanically convert mana to IfAPI
    
    Reviewed by:    zlei
    Sponsored by:   Juniper Networks, Inc.
    Differential Revision: https://reviews.freebsd.org/D37835
---
 sys/dev/mana/mana.h    | 14 ++++----
 sys/dev/mana/mana_en.c | 88 +++++++++++++++++++++++++-------------------------
 2 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/sys/dev/mana/mana.h b/sys/dev/mana/mana.h
index cb5ee66c2331..8784044d0cf0 100644
--- a/sys/dev/mana/mana.h
+++ b/sys/dev/mana/mana.h
@@ -155,7 +155,7 @@ struct mana_txq {
 
 	uint16_t		vp_offset;
 
-	struct ifnet		*ndev;
+	if_t			ndev;
 	/* Store index to the array of tx_qp in port structure */
 	int			idx;
 	/* The alternative txq idx when this txq is under heavy load */
@@ -416,7 +416,7 @@ struct mana_rxq {
 
 	struct mana_cq			rx_cq;
 
-	struct ifnet			*ndev;
+	if_t				ndev;
 	struct lro_ctrl			lro;
 
 	/* Total number of receive buffers to be allocated */
@@ -461,12 +461,12 @@ struct mana_context {
 
 	struct mana_eq		*eqs;
 
-	struct ifnet		*ports[MAX_PORTS_IN_MANA_DEV];
+	if_t			ports[MAX_PORTS_IN_MANA_DEV];
 };
 
 struct mana_port_context {
 	struct mana_context	*ac;
-	struct ifnet		*ndev;
+	if_t			ndev;
 	struct ifmedia		media;
 
 	struct sx		apc_lock;
@@ -533,9 +533,9 @@ struct mana_port_context {
 int mana_config_rss(struct mana_port_context *ac, enum TRI_STATE rx,
     bool update_hash, bool update_tab);
 
-int mana_alloc_queues(struct ifnet *ndev);
-int mana_attach(struct ifnet *ndev);
-int mana_detach(struct ifnet *ndev);
+int mana_alloc_queues(if_t ndev);
+int mana_attach(if_t ndev);
+int mana_detach(if_t ndev);
 
 int mana_probe(struct gdma_dev *gd);
 void mana_remove(struct gdma_dev *gd);
diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c
index 5a95eff66ab6..9d9a4084efe1 100644
--- a/sys/dev/mana/mana_en.c
+++ b/sys/dev/mana/mana_en.c
@@ -86,13 +86,13 @@ mana_rss_key_fill(void *k, size_t size)
 }
 
 static int
-mana_ifmedia_change(struct ifnet *ifp __unused)
+mana_ifmedia_change(if_t ifp __unused)
 {
 	return EOPNOTSUPP;
 }
 
 static void
-mana_ifmedia_status(struct ifnet *ifp, struct ifmediareq *ifmr)
+mana_ifmedia_status(if_t ifp, struct ifmediareq *ifmr)
 {
 	struct mana_port_context *apc = if_getsoftc(ifp);
 
@@ -119,7 +119,7 @@ mana_ifmedia_status(struct ifnet *ifp, struct ifmediareq *ifmr)
 }
 
 static uint64_t
-mana_get_counter(struct ifnet *ifp, ift_counter cnt)
+mana_get_counter(if_t ifp, ift_counter cnt)
 {
 	struct mana_port_context *apc = if_getsoftc(ifp);
 	struct mana_port_stats *stats = &apc->port_stats;
@@ -143,7 +143,7 @@ mana_get_counter(struct ifnet *ifp, ift_counter cnt)
 }
 
 static void
-mana_qflush(struct ifnet *ifp)
+mana_qflush(if_t ifp)
 {
 	if_qflush(ifp);
 }
@@ -164,7 +164,7 @@ mana_restart(struct mana_port_context *apc)
 }
 
 static int
-mana_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
+mana_ioctl(if_t ifp, u_long command, caddr_t data)
 {
 	struct mana_port_context *apc = if_getsoftc(ifp);
 	struct ifrsskey *ifrk;
@@ -177,7 +177,7 @@ mana_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 	case SIOCSIFMTU:
 		ifr = (struct ifreq *)data;
 		new_mtu = ifr->ifr_mtu;
-		if (ifp->if_mtu == new_mtu)
+		if (if_getmtu(ifp) == new_mtu)
 			break;
 		if ((new_mtu + 18 > MAX_FRAME_SIZE) ||
 		    (new_mtu + 18 < MIN_FRAME_SIZE)) {
@@ -199,15 +199,15 @@ mana_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 		break;
 
 	case SIOCSIFFLAGS:
-		if (ifp->if_flags & IFF_UP) {
-			if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+		if (if_getflags(ifp) & IFF_UP) {
+			if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) {
 				MANA_APC_LOCK_LOCK(apc);
 				if (!apc->port_is_up)
 					rc = mana_up(apc);
 				MANA_APC_LOCK_UNLOCK(apc);
 			}
 		} else {
-			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+			if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
 				MANA_APC_LOCK_LOCK(apc);
 				if (apc->port_is_up)
 					mana_down(apc);
@@ -416,7 +416,7 @@ mana_xmit(struct mana_txq *txq)
 {
 	enum mana_tx_pkt_format pkt_fmt = MANA_SHORT_PKT_FMT;
 	struct mana_send_buf_info *tx_info;
-	struct ifnet *ndev = txq->ndev;
+	if_t ndev = txq->ndev;
 	struct mbuf *mbuf;
 	struct mana_port_context *apc = if_getsoftc(ndev);
 	struct mana_port_stats *port_stats = &apc->port_stats;
@@ -584,7 +584,7 @@ static void
 mana_xmit_taskfunc(void *arg, int pending)
 {
 	struct mana_txq *txq = (struct mana_txq *)arg;
-	struct ifnet *ndev = txq->ndev;
+	if_t ndev = txq->ndev;
 	struct mana_port_context *apc = if_getsoftc(ndev);
 
 	while (!drbr_empty(ndev, txq->txq_br) && apc->port_is_up &&
@@ -717,7 +717,7 @@ mana_mbuf_csum_check(struct mbuf *mbuf)
 }
 
 static int
-mana_start_xmit(struct ifnet *ifp, struct mbuf *m)
+mana_start_xmit(if_t ifp, struct mbuf *m)
 {
 	struct mana_port_context *apc = if_getsoftc(ifp);
 	struct mana_txq *txq;
@@ -1073,7 +1073,7 @@ mana_cfg_vport_steering(struct mana_port_context *apc,
 	uint16_t num_entries = MANA_INDIRECT_TABLE_SIZE;
 	struct mana_cfg_rx_steer_req *req = NULL;
 	struct mana_cfg_rx_steer_resp resp = {};
-	struct ifnet *ndev = apc->ndev;
+	if_t ndev = apc->ndev;
 	mana_handle_t *req_indir_tab;
 	uint32_t req_buf_size;
 	int err;
@@ -1142,7 +1142,7 @@ mana_create_wq_obj(struct mana_port_context *apc,
 {
 	struct mana_create_wqobj_resp resp = {};
 	struct mana_create_wqobj_req req = {};
-	struct ifnet *ndev = apc->ndev;
+	if_t ndev = apc->ndev;
 	int err;
 
 	mana_gd_init_req_hdr(&req.hdr, MANA_CREATE_WQ_OBJ,
@@ -1194,7 +1194,7 @@ mana_destroy_wq_obj(struct mana_port_context *apc, uint32_t wq_type,
 {
 	struct mana_destroy_wqobj_resp resp = {};
 	struct mana_destroy_wqobj_req req = {};
-	struct ifnet *ndev = apc->ndev;
+	if_t ndev = apc->ndev;
 	int err;
 
 	mana_gd_init_req_hdr(&req.hdr, MANA_DESTROY_WQ_OBJ,
@@ -1359,7 +1359,7 @@ mana_poll_tx_cq(struct mana_cq *cq)
 	struct mana_txq *txq = cq->txq;
 	struct mana_port_context *apc;
 	uint16_t next_to_complete;
-	struct ifnet *ndev;
+	if_t ndev;
 	int comp_read;
 	int txq_idx = txq->idx;;
 	int i;
@@ -1550,7 +1550,7 @@ mana_rx_mbuf(struct mbuf *mbuf, struct mana_rxcomp_oob *cqe,
     struct mana_rxq *rxq)
 {
 	struct mana_stats *rx_stats = &rxq->stats;
-	struct ifnet *ndev = rxq->ndev;
+	if_t ndev = rxq->ndev;
 	uint32_t pkt_len = cqe->ppi[0].pkt_len;
 	uint16_t rxq_idx = rxq->rxq_idx;
 	struct mana_port_context *apc;
@@ -1569,8 +1569,8 @@ mana_rx_mbuf(struct mbuf *mbuf, struct mana_rxcomp_oob *cqe,
 	mbuf->m_len = pkt_len;
 	mbuf->m_pkthdr.rcvif = ndev;
 
-	if ((ndev->if_capenable & IFCAP_RXCSUM ||
-	    ndev->if_capenable & IFCAP_RXCSUM_IPV6) &&
+	if ((if_getcapenable(ndev) & IFCAP_RXCSUM ||
+	    if_getcapenable(ndev) & IFCAP_RXCSUM_IPV6) &&
 	    (cqe->rx_iphdr_csum_succeed)) {
 		mbuf->m_pkthdr.csum_flags = CSUM_IP_CHECKED;
 		mbuf->m_pkthdr.csum_flags |= CSUM_IP_VALID;
@@ -1629,13 +1629,13 @@ mana_rx_mbuf(struct mbuf *mbuf, struct mana_rxcomp_oob *cqe,
 	}
 
 	do_if_input = true;
-	if ((ndev->if_capenable & IFCAP_LRO) && do_lro) {
+	if ((if_getcapenable(ndev) & IFCAP_LRO) && do_lro) {
 		if (rxq->lro.lro_cnt != 0 &&
 		    tcp_lro_rx(&rxq->lro, mbuf, 0) == 0)
 			do_if_input = false;
 	}
 	if (do_if_input) {
-		ndev->if_input(ndev, mbuf);
+		if_input(ndev, mbuf);
 	}
 
 	counter_enter();
@@ -1652,7 +1652,7 @@ mana_process_rx_cqe(struct mana_rxq *rxq, struct mana_cq *cq,
 {
 	struct mana_rxcomp_oob *oob = (struct mana_rxcomp_oob *)cqe->cqe_data;
 	struct mana_recv_buf_oob *rxbuf_oob;
-	struct ifnet *ndev = rxq->ndev;
+	if_t ndev = rxq->ndev;
 	struct mana_port_context *apc;
 	struct mbuf *old_mbuf;
 	uint32_t curr, pktlen;
@@ -1938,7 +1938,7 @@ mana_destroy_txq(struct mana_port_context *apc)
 }
 
 static int
-mana_create_txq(struct mana_port_context *apc, struct ifnet *net)
+mana_create_txq(struct mana_port_context *apc, if_t net)
 {
 	struct mana_context *ac = apc->ac;
 	struct gdma_dev *gd = ac->gdma_dev;
@@ -2248,7 +2248,7 @@ mana_push_wqe(struct mana_rxq *rxq)
 
 static struct mana_rxq *
 mana_create_rxq(struct mana_port_context *apc, uint32_t rxq_idx,
-    struct mana_eq *eq, struct ifnet *ndev)
+    struct mana_eq *eq, if_t ndev)
 {
 	struct gdma_dev *gd = apc->ac->gdma_dev;
 	struct mana_obj_spec wq_spec;
@@ -2289,7 +2289,7 @@ mana_create_rxq(struct mana_port_context *apc, uint32_t rxq_idx,
 		goto out;
 
 	/* Create LRO for the RQ */
-	if (ndev->if_capenable & IFCAP_LRO) {
+	if (if_getcapenable(ndev) & IFCAP_LRO) {
 		err = tcp_lro_init(&rxq->lro);
 		if (err) {
 			if_printf(ndev, "Failed to create LRO for rxq %d\n",
@@ -2408,7 +2408,7 @@ out:
 }
 
 static int
-mana_add_rx_queues(struct mana_port_context *apc, struct ifnet *ndev)
+mana_add_rx_queues(struct mana_port_context *apc, if_t ndev)
 {
 	struct mana_context *ac = apc->ac;
 	struct mana_rxq *rxq;
@@ -2451,7 +2451,7 @@ mana_destroy_vport(struct mana_port_context *apc)
 }
 
 static int
-mana_create_vport(struct mana_port_context *apc, struct ifnet *net)
+mana_create_vport(struct mana_port_context *apc, if_t net)
 {
 	struct gdma_dev *gd = apc->ac->gdma_dev;
 	int err;
@@ -2498,7 +2498,7 @@ int mana_config_rss(struct mana_port_context *apc, enum TRI_STATE rx,
 }
 
 static int
-mana_init_port(struct ifnet *ndev)
+mana_init_port(if_t ndev)
 {
 	struct mana_port_context *apc = if_getsoftc(ndev);
 	uint32_t max_txq, max_rxq, max_queues;
@@ -2536,7 +2536,7 @@ reset_apc:
 }
 
 int
-mana_alloc_queues(struct ifnet *ndev)
+mana_alloc_queues(if_t ndev)
 {
 	struct mana_port_context *apc = if_getsoftc(ndev);
 	int err;
@@ -2605,7 +2605,7 @@ mana_init(void *arg)
 }
 
 static int
-mana_dealloc_queues(struct ifnet *ndev)
+mana_dealloc_queues(if_t ndev)
 {
 	struct mana_port_context *apc = if_getsoftc(ndev);
 	struct mana_txq *txq;
@@ -2683,7 +2683,7 @@ mana_down(struct mana_port_context *apc)
 }
 
 int
-mana_detach(struct ifnet *ndev)
+mana_detach(if_t ndev)
 {
 	struct mana_port_context *apc = if_getsoftc(ndev);
 	int err;
@@ -2708,11 +2708,11 @@ mana_detach(struct ifnet *ndev)
 
 static int
 mana_probe_port(struct mana_context *ac, int port_idx,
-    struct ifnet **ndev_storage)
+    if_t *ndev_storage)
 {
 	struct gdma_context *gc = ac->gdma_dev->gdma_context;
 	struct mana_port_context *apc;
-	struct ifnet *ndev;
+	if_t ndev;
 	int err;
 
 	ndev = if_alloc_dev(IFT_ETHER, gc->dev);
@@ -2764,20 +2764,20 @@ mana_probe_port(struct mana_context *ac, int port_idx,
 	if (err)
 		goto reset_apc;
 
-	ndev->if_capabilities |= IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6;
-	ndev->if_capabilities |= IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6;
-	ndev->if_capabilities |= IFCAP_TSO4 | IFCAP_TSO6;
-
-	ndev->if_capabilities |= IFCAP_LRO | IFCAP_LINKSTATE;
+	if_setcapabilitiesbit(ndev,
+	    IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6 |
+	    IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6 |
+	    IFCAP_TSO4 | IFCAP_TSO6 |
+	    IFCAP_LRO | IFCAP_LINKSTATE, 0);
 
 	/* Enable all available capabilities by default. */
-	ndev->if_capenable = ndev->if_capabilities;
+	if_setcapenable(ndev, if_getcapabilities(ndev));
 
 	/* TSO parameters */
-	ndev->if_hw_tsomax = MAX_MBUF_FRAGS * MANA_TSO_MAXSEG_SZ -
-	    (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
-	ndev->if_hw_tsomaxsegcount = MAX_MBUF_FRAGS;
-	ndev->if_hw_tsomaxsegsize = PAGE_SIZE;
+	if_sethwtsomax(ndev, MAX_MBUF_FRAGS * MANA_TSO_MAXSEG_SZ -
+	    (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN));
+	if_sethwtsomaxsegcount(ndev, MAX_MBUF_FRAGS);
+	if_sethwtsomaxsegsize(ndev, PAGE_SIZE);
 
 	ifmedia_init(&apc->media, IFM_IMASK,
 	    mana_ifmedia_change, mana_ifmedia_status);
@@ -2862,7 +2862,7 @@ mana_remove(struct gdma_dev *gd)
 	struct gdma_context *gc = gd->gdma_context;
 	struct mana_context *ac = gd->driver_data;
 	device_t dev = gc->dev;
-	struct ifnet *ndev;
+	if_t ndev;
 	int i;
 
 	for (i = 0; i < ac->num_ports; i++) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302071918.317JIF2r049890>