Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Feb 2023 19:18:12 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: b9545c579415 - main - Mechanically convert vnic to IfAPI
Message-ID:  <202302071918.317JIC15049812@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=b9545c57941598857677c31b90c707123d8f4976

commit b9545c57941598857677c31b90c707123d8f4976
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2022-08-17 20:42:35 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2023-02-07 19:16:17 +0000

    Mechanically convert vnic to IfAPI
    
    Reviewed by:    zlei
    Sponsored by:   Juniper Networks, Inc.
    Differential Revision: https://reviews.freebsd.org/D37827
---
 sys/dev/vnic/nic.h              |  2 +-
 sys/dev/vnic/nicvf_main.c       | 30 +++++++++++++++---------------
 sys/dev/vnic/nicvf_queues.c     | 10 +++++-----
 sys/dev/vnic/thunder_mdio.c     |  8 ++++----
 sys/dev/vnic/thunder_mdio_fdt.c |  3 +++
 sys/dev/vnic/thunder_mdio_var.h |  2 +-
 6 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/sys/dev/vnic/nic.h b/sys/dev/vnic/nic.h
index dba91af666d6..2dcaffe1628c 100644
--- a/sys/dev/vnic/nic.h
+++ b/sys/dev/vnic/nic.h
@@ -292,7 +292,7 @@ struct nicvf {
 	struct nicvf		*pnicvf;
 	device_t		dev;
 
-	struct ifnet *		ifp;
+	if_t 			ifp;
 	struct sx		core_sx;
 	struct ifmedia		if_media;
 	uint32_t		if_flags;
diff --git a/sys/dev/vnic/nicvf_main.c b/sys/dev/vnic/nicvf_main.c
index 54efc58fee22..b135c745b902 100644
--- a/sys/dev/vnic/nicvf_main.c
+++ b/sys/dev/vnic/nicvf_main.c
@@ -147,17 +147,17 @@ static int nicvf_setup_ifnet(struct nicvf *);
 static int nicvf_setup_ifmedia(struct nicvf *);
 static void nicvf_hw_addr_random(uint8_t *);
 
-static int nicvf_if_ioctl(struct ifnet *, u_long, caddr_t);
+static int nicvf_if_ioctl(if_t, u_long, caddr_t);
 static void nicvf_if_init(void *);
 static void nicvf_if_init_locked(struct nicvf *);
-static int nicvf_if_transmit(struct ifnet *, struct mbuf *);
-static void nicvf_if_qflush(struct ifnet *);
-static uint64_t nicvf_if_getcounter(struct ifnet *, ift_counter);
+static int nicvf_if_transmit(if_t, struct mbuf *);
+static void nicvf_if_qflush(if_t);
+static uint64_t nicvf_if_getcounter(if_t, ift_counter);
 
 static int nicvf_stop_locked(struct nicvf *);
 
-static void nicvf_media_status(struct ifnet *, struct ifmediareq *);
-static int nicvf_media_change(struct ifnet *);
+static void nicvf_media_status(if_t, struct ifmediareq *);
+static int nicvf_media_change(if_t);
 
 static void nicvf_tick_stats(void *);
 
@@ -336,7 +336,7 @@ nicvf_hw_addr_random(uint8_t *hwaddr)
 static int
 nicvf_setup_ifnet(struct nicvf *nic)
 {
-	struct ifnet *ifp;
+	if_t ifp;
 
 	ifp = if_alloc(IFT_ETHER);
 	if (ifp == NULL) {
@@ -418,7 +418,7 @@ nicvf_setup_ifmedia(struct nicvf *nic)
 }
 
 static int
-nicvf_if_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
+nicvf_if_ioctl(if_t ifp, u_long cmd, caddr_t data)
 {
 	struct nicvf *nic;
 	struct rcv_queue *rq;
@@ -571,7 +571,7 @@ static void
 nicvf_if_init_locked(struct nicvf *nic)
 {
 	struct queue_set *qs = nic->qs;
-	struct ifnet *ifp;
+	if_t ifp;
 	int qidx;
 	int err;
 	caddr_t if_addr;
@@ -643,7 +643,7 @@ nicvf_if_init(void *if_softc)
 }
 
 static int
-nicvf_if_transmit(struct ifnet *ifp, struct mbuf *mbuf)
+nicvf_if_transmit(if_t ifp, struct mbuf *mbuf)
 {
 	struct nicvf *nic = if_getsoftc(ifp);
 	struct queue_set *qs = nic->qs;
@@ -699,7 +699,7 @@ nicvf_if_transmit(struct ifnet *ifp, struct mbuf *mbuf)
 }
 
 static void
-nicvf_if_qflush(struct ifnet *ifp)
+nicvf_if_qflush(if_t ifp)
 {
 	struct nicvf *nic;
 	struct queue_set *qs;
@@ -721,7 +721,7 @@ nicvf_if_qflush(struct ifnet *ifp)
 }
 
 static uint64_t
-nicvf_if_getcounter(struct ifnet *ifp, ift_counter cnt)
+nicvf_if_getcounter(if_t ifp, ift_counter cnt)
 {
 	struct nicvf *nic;
 	struct nicvf_hw_stats *hw_stats;
@@ -755,7 +755,7 @@ nicvf_if_getcounter(struct ifnet *ifp, ift_counter cnt)
 }
 
 static void
-nicvf_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
+nicvf_media_status(if_t ifp, struct ifmediareq *ifmr)
 {
 	struct nicvf *nic = if_getsoftc(ifp);
 
@@ -799,7 +799,7 @@ nicvf_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
 }
 
 static int
-nicvf_media_change(struct ifnet *ifp __unused)
+nicvf_media_change(if_t ifp __unused)
 {
 
 	return (0);
@@ -1523,7 +1523,7 @@ error:
 static int
 nicvf_stop_locked(struct nicvf *nic)
 {
-	struct ifnet *ifp;
+	if_t ifp;
 	int qidx;
 	struct queue_set *qs = nic->qs;
 	union nic_mbx mbx = {};
diff --git a/sys/dev/vnic/nicvf_queues.c b/sys/dev/vnic/nicvf_queues.c
index d2a6f8532b37..017d1c6e3e1c 100644
--- a/sys/dev/vnic/nicvf_queues.c
+++ b/sys/dev/vnic/nicvf_queues.c
@@ -732,7 +732,7 @@ static int
 nicvf_cq_intr_handler(struct nicvf *nic, uint8_t cq_idx)
 {
 	struct mbuf *mbuf;
-	struct ifnet *ifp;
+	if_t ifp;
 	int processed_cqe, tx_done = 0;
 #ifdef DEBUG
 	int work_done = 0;
@@ -831,7 +831,7 @@ out:
 	while (!buf_ring_empty(cq->rx_br)) {
 		mbuf = buf_ring_dequeue_mc(cq->rx_br);
 		if (__predict_true(mbuf != NULL))
-			(*ifp->if_input)(ifp, mbuf);
+			if_input(ifp, mbuf);
 	}
 
 	return (cmp_err);
@@ -987,7 +987,7 @@ int
 nicvf_xmit_locked(struct snd_queue *sq)
 {
 	struct nicvf *nic;
-	struct ifnet *ifp;
+	if_t ifp;
 	struct mbuf *next;
 	int err;
 
@@ -1020,7 +1020,7 @@ nicvf_snd_task(void *arg, int pending)
 {
 	struct snd_queue *sq = (struct snd_queue *)arg;
 	struct nicvf *nic;
-	struct ifnet *ifp;
+	if_t ifp;
 	int err;
 
 	nic = sq->nic;
@@ -1296,7 +1296,7 @@ nicvf_rcv_queue_config(struct nicvf *nic, struct queue_set *qs,
 	union nic_mbx mbx = {};
 	struct rcv_queue *rq;
 	struct rq_cfg rq_cfg;
-	struct ifnet *ifp;
+	if_t ifp;
 	struct lro_ctrl	*lro;
 
 	ifp = nic->ifp;
diff --git a/sys/dev/vnic/thunder_mdio.c b/sys/dev/vnic/thunder_mdio.c
index d07b17b56a2e..3e9a8f74e673 100644
--- a/sys/dev/vnic/thunder_mdio.c
+++ b/sys/dev/vnic/thunder_mdio.c
@@ -93,8 +93,8 @@ static int thunder_mdio_detach(device_t);
 static int thunder_mdio_read(device_t, int, int);
 static int thunder_mdio_write(device_t, int, int, int);
 
-static int thunder_ifmedia_change_stub(struct ifnet *);
-static void thunder_ifmedia_status_stub(struct ifnet *, struct ifmediareq *);
+static int thunder_ifmedia_change_stub(if_t);
+static void thunder_ifmedia_status_stub(if_t, struct ifmediareq *);
 
 static int thunder_mdio_media_status(device_t, int, int *, int *, int *);
 static int thunder_mdio_media_change(device_t, int, int, int, int);
@@ -351,14 +351,14 @@ thunder_mdio_write(device_t dev, int phy, int reg, int data)
 }
 
 static int
-thunder_ifmedia_change_stub(struct ifnet *ifp __unused)
+thunder_ifmedia_change_stub(if_t ifp __unused)
 {
 	/* Will never be called by if_media */
 	return (0);
 }
 
 static void
-thunder_ifmedia_status_stub(struct ifnet *ifp __unused, struct ifmediareq
+thunder_ifmedia_status_stub(if_t ifp __unused, struct ifmediareq
     *ifmr __unused)
 {
 	/* Will never be called by if_media */
diff --git a/sys/dev/vnic/thunder_mdio_fdt.c b/sys/dev/vnic/thunder_mdio_fdt.c
index fd3905453008..d6d46b04a17f 100644
--- a/sys/dev/vnic/thunder_mdio_fdt.c
+++ b/sys/dev/vnic/thunder_mdio_fdt.c
@@ -34,11 +34,14 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
+#include <sys/socket.h>
 
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
 #include <dev/fdt/simplebus.h>
 
+#include <net/if.h>
+
 #include <machine/bus.h>
 #include <machine/resource.h>
 
diff --git a/sys/dev/vnic/thunder_mdio_var.h b/sys/dev/vnic/thunder_mdio_var.h
index acebec0dbcc0..c66c5e9683df 100644
--- a/sys/dev/vnic/thunder_mdio_var.h
+++ b/sys/dev/vnic/thunder_mdio_var.h
@@ -44,7 +44,7 @@ enum thunder_mdio_mode {
 
 struct phy_desc {
 	device_t		miibus; /* One miibus per LMAC */
-	struct ifnet *		ifp;	/* Fake ifp to satisfy miibus */
+	if_t 			ifp;	/* Fake ifp to satisfy miibus */
 	int			lmacid;	/* ID number of LMAC connected */
 	TAILQ_ENTRY(phy_desc)	phy_desc_list;
 };



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