git: ff06a8dbb677 - main - Mechanically convert ixgbe(4) to IfAPI
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Jan 2023 20:48:26 UTC
The branch main has been updated by jhibbits:
URL: https://cgit.FreeBSD.org/src/commit/?id=ff06a8dbb6777a0475ae961faacd776225cb8791
commit ff06a8dbb6777a0475ae961faacd776225cb8791
Author: Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2022-08-20 02:02:03 +0000
Commit: Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2023-01-24 20:05:28 +0000
Mechanically convert ixgbe(4) to IfAPI
Reviewed by: erj
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37845
---
sys/dev/ixgbe/if_fdir.c | 4 ++--
sys/dev/ixgbe/if_ix.c | 58 ++++++++++++++++++++++++------------------------
sys/dev/ixgbe/if_ixv.c | 49 ++++++++++++++++++++--------------------
sys/dev/ixgbe/if_sriov.c | 4 ++--
4 files changed, 58 insertions(+), 57 deletions(-)
diff --git a/sys/dev/ixgbe/if_fdir.c b/sys/dev/ixgbe/if_fdir.c
index 22b71f2bdf09..dd84cfe0a447 100644
--- a/sys/dev/ixgbe/if_fdir.c
+++ b/sys/dev/ixgbe/if_fdir.c
@@ -54,7 +54,7 @@ ixgbe_reinit_fdir(void *context)
{
if_ctx_t ctx = context;
struct ixgbe_softc *sc = iflib_get_softc(ctx);
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
if (!(sc->feat_en & IXGBE_FEATURE_FDIR))
return;
@@ -65,7 +65,7 @@ ixgbe_reinit_fdir(void *context)
/* re-enable flow director interrupts */
IXGBE_WRITE_REG(&sc->hw, IXGBE_EIMS, IXGBE_EIMS_FLOW_DIR);
/* Restart the interface */
- ifp->if_drv_flags |= IFF_DRV_RUNNING;
+ if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
} /* ixgbe_reinit_fdir */
/************************************************************************
diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c
index 1d472d7df628..4f6faeec4296 100644
--- a/sys/dev/ixgbe/if_ix.c
+++ b/sys/dev/ixgbe/if_ix.c
@@ -666,7 +666,7 @@ ixgbe_initialize_receive_units(if_ctx_t ctx)
struct ixgbe_softc *sc = iflib_get_softc(ctx);
if_softc_ctx_t scctx = sc->shared;
struct ixgbe_hw *hw = &sc->hw;
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
struct ix_rx_queue *que;
int i, j;
u32 bufsz, fctrl, srrctl, rxcsum;
@@ -689,7 +689,7 @@ ixgbe_initialize_receive_units(if_ctx_t ctx)
/* Set for Jumbo Frames? */
hlreg = IXGBE_READ_REG(hw, IXGBE_HLREG0);
- if (ifp->if_mtu > ETHERMTU)
+ if (if_getmtu(ifp) > ETHERMTU)
hlreg |= IXGBE_HLREG0_JUMBOEN;
else
hlreg &= ~IXGBE_HLREG0_JUMBOEN;
@@ -759,7 +759,7 @@ ixgbe_initialize_receive_units(if_ctx_t ctx)
rxcsum |= IXGBE_RXCSUM_PCSD;
}
- if (ifp->if_capenable & IFCAP_RXCSUM)
+ if (if_getcapenable(ifp) & IFCAP_RXCSUM)
rxcsum |= IXGBE_RXCSUM_PCSD;
/* This is useful for calculating UDP/IP fragment checksums */
@@ -1170,14 +1170,14 @@ ixgbe_check_wol_support(struct ixgbe_softc *sc)
static int
ixgbe_setup_interface(if_ctx_t ctx)
{
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
struct ixgbe_softc *sc = iflib_get_softc(ctx);
INIT_DEBUGOUT("ixgbe_setup_interface: begin");
if_setbaudrate(ifp, IF_Gbps(10));
- sc->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+ sc->max_frame_size = if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN;
sc->phy_layer = ixgbe_get_supported_physical_layer(&sc->hw);
@@ -1915,7 +1915,7 @@ ixgbe_if_vlan_unregister(if_ctx_t ctx, u16 vtag)
static void
ixgbe_setup_vlan_hw_support(if_ctx_t ctx)
{
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
struct ixgbe_softc *sc = iflib_get_softc(ctx);
struct ixgbe_hw *hw = &sc->hw;
struct rx_ring *rxr;
@@ -1929,7 +1929,7 @@ ixgbe_setup_vlan_hw_support(if_ctx_t ctx)
* the VFTA and other state, so if there
* have been no vlan's registered do nothing.
*/
- if (sc->num_vlans == 0 || (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0) {
+ if (sc->num_vlans == 0 || (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) == 0) {
/* Clear the vlan hw flag */
for (i = 0; i < sc->num_rx_queues; i++) {
rxr = &sc->rx_queues[i].rxr;
@@ -1952,7 +1952,7 @@ ixgbe_setup_vlan_hw_support(if_ctx_t ctx)
}
/* Setup the queues for vlans */
- if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) {
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) {
for (i = 0; i < sc->num_rx_queues; i++) {
rxr = &sc->rx_queues[i].rxr;
/* On 82599 the VLAN enable is per/queue in RXDCTL */
@@ -1965,7 +1965,7 @@ ixgbe_setup_vlan_hw_support(if_ctx_t ctx)
}
}
- if ((ifp->if_capenable & IFCAP_VLAN_HWFILTER) == 0)
+ if ((if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER) == 0)
return;
/*
* A soft reset zero's out the VFTA, so
@@ -1978,7 +1978,7 @@ ixgbe_setup_vlan_hw_support(if_ctx_t ctx)
ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
/* Enable the Filter Table if enabled */
- if (ifp->if_capenable & IFCAP_VLAN_HWFILTER) {
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER) {
ctrl &= ~IXGBE_VLNCTRL_CFIEN;
ctrl |= IXGBE_VLNCTRL_VFE;
}
@@ -2208,10 +2208,10 @@ ixgbe_msix_que(void *arg)
{
struct ix_rx_queue *que = arg;
struct ixgbe_softc *sc = que->sc;
- struct ifnet *ifp = iflib_get_ifp(que->sc->ctx);
+ if_t ifp = iflib_get_ifp(que->sc->ctx);
/* Protect against spurious interrupts */
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
return (FILTER_HANDLED);
ixgbe_disable_queue(sc, que->msix);
@@ -2493,13 +2493,13 @@ static int
ixgbe_if_promisc_set(if_ctx_t ctx, int flags)
{
struct ixgbe_softc *sc = iflib_get_softc(ctx);
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
u32 rctl;
int mcnt = 0;
rctl = IXGBE_READ_REG(&sc->hw, IXGBE_FCTRL);
rctl &= (~IXGBE_FCTRL_UPE);
- if (ifp->if_flags & IFF_ALLMULTI)
+ if (if_getflags(ifp) & IFF_ALLMULTI)
mcnt = MAX_NUM_MULTICAST_ADDRESSES;
else {
mcnt = min(if_llmaddr_count(ifp), MAX_NUM_MULTICAST_ADDRESSES);
@@ -2508,10 +2508,10 @@ ixgbe_if_promisc_set(if_ctx_t ctx, int flags)
rctl &= (~IXGBE_FCTRL_MPE);
IXGBE_WRITE_REG(&sc->hw, IXGBE_FCTRL, rctl);
- if (ifp->if_flags & IFF_PROMISC) {
+ if (if_getflags(ifp) & IFF_PROMISC) {
rctl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
IXGBE_WRITE_REG(&sc->hw, IXGBE_FCTRL, rctl);
- } else if (ifp->if_flags & IFF_ALLMULTI) {
+ } else if (if_getflags(ifp) & IFF_ALLMULTI) {
rctl |= IXGBE_FCTRL_MPE;
rctl &= ~IXGBE_FCTRL_UPE;
IXGBE_WRITE_REG(&sc->hw, IXGBE_FCTRL, rctl);
@@ -2926,7 +2926,7 @@ ixgbe_if_resume(if_ctx_t ctx)
{
struct ixgbe_softc *sc = iflib_get_softc(ctx);
device_t dev = iflib_get_dev(ctx);
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
struct ixgbe_hw *hw = &sc->hw;
u32 wus;
@@ -2945,7 +2945,7 @@ ixgbe_if_resume(if_ctx_t ctx)
* Required after D3->D0 transition;
* will re-advertise all previous advertised speeds
*/
- if (ifp->if_flags & IFF_UP)
+ if (if_getflags(ifp) & IFF_UP)
ixgbe_if_init(ctx);
return (0);
@@ -3033,7 +3033,7 @@ void
ixgbe_if_init(if_ctx_t ctx)
{
struct ixgbe_softc *sc = iflib_get_softc(ctx);
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
device_t dev = iflib_get_dev(ctx);
struct ixgbe_hw *hw = &sc->hw;
struct ix_rx_queue *rx_que;
@@ -3053,7 +3053,7 @@ ixgbe_if_init(if_ctx_t ctx)
ixgbe_set_rar(hw, 0, hw->mac.addr, sc->pool, IXGBE_RAH_AV);
/* Get the latest mac address, User can use a LAA */
- bcopy(IF_LLADDR(ifp), hw->mac.addr, IXGBE_ETH_LENGTH_OF_ADDRESS);
+ bcopy(if_getlladdr(ifp), hw->mac.addr, IXGBE_ETH_LENGTH_OF_ADDRESS);
ixgbe_set_rar(hw, 0, hw->mac.addr, sc->pool, 1);
hw->addr_ctrl.rar_used_count = 1;
@@ -3082,7 +3082,7 @@ ixgbe_if_init(if_ctx_t ctx)
ixgbe_config_gpie(sc);
/* Set MTU size */
- if (ifp->if_mtu > ETHERMTU) {
+ if (if_getmtu(ifp) > ETHERMTU) {
/* aka IXGBE_MAXFRS on 82599 and newer */
mhadd = IXGBE_READ_REG(hw, IXGBE_MHADD);
mhadd &= ~IXGBE_MHADD_MFS_MASK;
@@ -3412,7 +3412,7 @@ ixgbe_if_multi_set(if_ctx_t ctx)
{
struct ixgbe_softc *sc = iflib_get_softc(ctx);
struct ixgbe_mc_addr *mta;
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
u8 *update_ptr;
u32 fctrl;
u_int mcnt;
@@ -3432,10 +3432,10 @@ ixgbe_if_multi_set(if_ctx_t ctx)
fctrl = IXGBE_READ_REG(&sc->hw, IXGBE_FCTRL);
- if (ifp->if_flags & IFF_PROMISC)
+ if (if_getflags(ifp) & IFF_PROMISC)
fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
else if (mcnt >= MAX_NUM_MULTICAST_ADDRESSES ||
- ifp->if_flags & IFF_ALLMULTI) {
+ if_getflags(ifp) & IFF_ALLMULTI) {
fctrl |= IXGBE_FCTRL_MPE;
fctrl &= ~IXGBE_FCTRL_UPE;
} else
@@ -4316,7 +4316,7 @@ static int
ixgbe_sysctl_dmac(SYSCTL_HANDLER_ARGS)
{
struct ixgbe_softc *sc = (struct ixgbe_softc *)arg1;
- struct ifnet *ifp = iflib_get_ifp(sc->ctx);
+ if_t ifp = iflib_get_ifp(sc->ctx);
int error;
u16 newval;
@@ -4351,8 +4351,8 @@ ixgbe_sysctl_dmac(SYSCTL_HANDLER_ARGS)
}
/* Re-initialize hardware if it's already running */
- if (ifp->if_drv_flags & IFF_DRV_RUNNING)
- ifp->if_init(ifp);
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
+ if_init(ifp, ifp);
return (0);
} /* ixgbe_sysctl_dmac */
@@ -4606,7 +4606,7 @@ ixgbe_sysctl_eee_state(SYSCTL_HANDLER_ARGS)
{
struct ixgbe_softc *sc = (struct ixgbe_softc *)arg1;
device_t dev = sc->dev;
- struct ifnet *ifp = iflib_get_ifp(sc->ctx);
+ if_t ifp = iflib_get_ifp(sc->ctx);
int curr_eee, new_eee, error = 0;
s32 retval;
@@ -4635,7 +4635,7 @@ ixgbe_sysctl_eee_state(SYSCTL_HANDLER_ARGS)
}
/* Restart auto-neg */
- ifp->if_init(ifp);
+ if_init(ifp, ifp);
device_printf(dev, "New EEE state: %d\n", new_eee);
diff --git a/sys/dev/ixgbe/if_ixv.c b/sys/dev/ixgbe/if_ixv.c
index d4c8067e2a0c..848c15fe3b99 100644
--- a/sys/dev/ixgbe/if_ixv.c
+++ b/sys/dev/ixgbe/if_ixv.c
@@ -574,15 +574,15 @@ static int
ixv_if_mtu_set(if_ctx_t ctx, uint32_t mtu)
{
struct ixgbe_softc *sc = iflib_get_softc(ctx);
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
int error = 0;
IOCTL_DEBUGOUT("ioctl: SIOCSIFMTU (Set Interface MTU)");
if (mtu > IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR) {
error = EINVAL;
} else {
- ifp->if_mtu = mtu;
- sc->max_frame_size = ifp->if_mtu + IXGBE_MTU_HDR;
+ if_setmtu(ifp, mtu);
+ sc->max_frame_size = if_getmtu(ifp) + IXGBE_MTU_HDR;
}
return error;
@@ -602,7 +602,7 @@ static void
ixv_if_init(if_ctx_t ctx)
{
struct ixgbe_softc *sc = iflib_get_softc(ctx);
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
device_t dev = iflib_get_dev(ctx);
struct ixgbe_hw *hw = &sc->hw;
int error = 0;
@@ -615,7 +615,7 @@ ixv_if_init(if_ctx_t ctx)
hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
/* Get the latest mac address, User can use a LAA */
- bcopy(IF_LLADDR(ifp), hw->mac.addr, IXGBE_ETH_LENGTH_OF_ADDRESS);
+ bcopy(if_getlladdr(ifp), hw->mac.addr, IXGBE_ETH_LENGTH_OF_ADDRESS);
hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, 1);
/* Reset VF and renegotiate mailbox API version */
@@ -834,6 +834,15 @@ ixv_negotiate_api(struct ixgbe_softc *sc)
} /* ixv_negotiate_api */
+static u_int
+ixv_if_multi_set_cb(void *cb_arg, struct sockaddr_dl *addr, u_int cnt)
+{
+ bcopy(LLADDR(addr), &((u8 *)cb_arg)[cnt * IXGBE_ETH_LENGTH_OF_ADDRESS],
+ IXGBE_ETH_LENGTH_OF_ADDRESS);
+
+ return (++cnt);
+}
+
/************************************************************************
* ixv_if_multi_set - Multicast Update
*
@@ -845,20 +854,12 @@ ixv_if_multi_set(if_ctx_t ctx)
u8 mta[MAX_NUM_MULTICAST_ADDRESSES * IXGBE_ETH_LENGTH_OF_ADDRESS];
struct ixgbe_softc *sc = iflib_get_softc(ctx);
u8 *update_ptr;
- struct ifmultiaddr *ifma;
if_t ifp = iflib_get_ifp(ctx);
int mcnt = 0;
IOCTL_DEBUGOUT("ixv_if_multi_set: begin");
- CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
- &mta[mcnt * IXGBE_ETH_LENGTH_OF_ADDRESS],
- IXGBE_ETH_LENGTH_OF_ADDRESS);
- mcnt++;
- }
+ mcnt = if_foreach_llmaddr(ifp, ixv_if_multi_set_cb, mta);
update_ptr = mta;
@@ -925,7 +926,7 @@ ixv_if_update_admin_status(if_ctx_t ctx)
if (status != IXGBE_SUCCESS && sc->hw.adapter_stopped == false) {
/* Mailbox's Clear To Send status is lost or timeout occurred.
* We need reinitialization. */
- iflib_get_ifp(ctx)->if_init(ctx);
+ if_init(iflib_get_ifp(ctx), ctx);
}
if (sc->link_up && sc->link_enabled) {
@@ -1159,15 +1160,15 @@ ixv_setup_interface(if_ctx_t ctx)
{
struct ixgbe_softc *sc = iflib_get_softc(ctx);
if_softc_ctx_t scctx = sc->shared;
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
INIT_DEBUGOUT("ixv_setup_interface: begin");
if_setbaudrate(ifp, IF_Gbps(10));
- ifp->if_snd.ifq_maxlen = scctx->isc_ntxd[0] - 2;
+ if_setsendqlen(ifp, scctx->isc_ntxd[0] - 2);
- sc->max_frame_size = ifp->if_mtu + IXGBE_MTU_HDR;
+ sc->max_frame_size = if_getmtu(ifp) + IXGBE_MTU_HDR;
ifmedia_add(sc->media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(sc->media, IFM_ETHER | IFM_AUTO);
@@ -1379,11 +1380,11 @@ ixv_initialize_receive_units(if_ctx_t ctx)
struct ixgbe_softc *sc = iflib_get_softc(ctx);
if_softc_ctx_t scctx;
struct ixgbe_hw *hw = &sc->hw;
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
struct ix_rx_queue *que = sc->rx_queues;
u32 bufsz, psrtype;
- if (ifp->if_mtu > ETHERMTU)
+ if (if_getmtu(ifp) > ETHERMTU)
bufsz = 4096 >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
else
bufsz = 2048 >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
@@ -1474,7 +1475,7 @@ ixv_initialize_receive_units(if_ctx_t ctx)
* RDT points to the last slot available for reception (?),
* so RDT = num_rx_desc - 1 means the whole ring is available.
*/
- if (ifp->if_capenable & IFCAP_NETMAP) {
+ if (if_getcapenable(ifp) & IFCAP_NETMAP) {
struct netmap_adapter *na = NA(ifp);
struct netmap_kring *kring = na->rx_rings[j];
int t = na->num_rx_desc - 1 - nm_kr_rxspace(kring);
@@ -1500,7 +1501,7 @@ ixv_initialize_receive_units(if_ctx_t ctx)
static void
ixv_setup_vlan_support(if_ctx_t ctx)
{
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
struct ixgbe_softc *sc = iflib_get_softc(ctx);
struct ixgbe_hw *hw = &sc->hw;
u32 ctrl, vid, vfta, retry;
@@ -1514,7 +1515,7 @@ ixv_setup_vlan_support(if_ctx_t ctx)
if (sc->num_vlans == 0)
return;
- if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) {
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) {
/* Enable the queues */
for (int i = 0; i < sc->num_rx_queues; i++) {
ctrl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i));
@@ -1532,7 +1533,7 @@ ixv_setup_vlan_support(if_ctx_t ctx)
* If filtering VLAN tags is disabled,
* there is no need to fill VLAN Filter Table Array (VFTA).
*/
- if ((ifp->if_capenable & IFCAP_VLAN_HWFILTER) == 0)
+ if ((if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER) == 0)
return;
/*
diff --git a/sys/dev/ixgbe/if_sriov.c b/sys/dev/ixgbe/if_sriov.c
index 5462aac56acc..6711c281c35e 100644
--- a/sys/dev/ixgbe/if_sriov.c
+++ b/sys/dev/ixgbe/if_sriov.c
@@ -575,7 +575,7 @@ ixgbe_process_vf_msg(if_ctx_t ctx, struct ixgbe_vf *vf)
{
struct ixgbe_softc *sc = iflib_get_softc(ctx);
#ifdef KTR
- struct ifnet *ifp = iflib_get_ifp(ctx);
+ if_t ifp = iflib_get_ifp(ctx);
#endif
struct ixgbe_hw *hw;
uint32_t msg[IXGBE_VFMAILBOX_SIZE];
@@ -588,7 +588,7 @@ ixgbe_process_vf_msg(if_ctx_t ctx, struct ixgbe_vf *vf)
if (error != 0)
return;
- CTR3(KTR_MALLOC, "%s: received msg %x from %d", ifp->if_xname,
+ CTR3(KTR_MALLOC, "%s: received msg %x from %d", if_name(ifp),
msg[0], vf->pool);
if (msg[0] == IXGBE_VF_RESET) {
ixgbe_vf_reset_msg(sc, vf, msg);