Mechanically convert ena(4) to DrvAPI
Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D37837
This commit is contained in:
parent
e5de1d8dad
commit
7583c633e0
@ -575,7 +575,7 @@ ena_release_all_tx_dmamap(struct ena_ring *tx_ring)
|
||||
for (i = 0; i < tx_ring->ring_size; ++i) {
|
||||
tx_info = &tx_ring->tx_buffer_info[i];
|
||||
#ifdef DEV_NETMAP
|
||||
if (adapter->ifp->if_capenable & IFCAP_NETMAP) {
|
||||
if (if_getcapenable(adapter->ifp) & IFCAP_NETMAP) {
|
||||
nm_info = &tx_info->nm_info;
|
||||
for (j = 0; j < ENA_PKT_MAX_BUFS; ++j) {
|
||||
if (nm_info->map_seg[j] != NULL) {
|
||||
@ -661,7 +661,7 @@ ena_setup_tx_resources(struct ena_adapter *adapter, int qid)
|
||||
}
|
||||
|
||||
#ifdef DEV_NETMAP
|
||||
if (adapter->ifp->if_capenable & IFCAP_NETMAP) {
|
||||
if (if_getcapenable(adapter->ifp) & IFCAP_NETMAP) {
|
||||
map = tx_ring->tx_buffer_info[i].nm_info.map_seg;
|
||||
for (j = 0; j < ENA_PKT_MAX_BUFS; j++) {
|
||||
err = bus_dmamap_create(adapter->tx_buf_tag, 0,
|
||||
@ -750,7 +750,7 @@ ena_free_tx_resources(struct ena_adapter *adapter, int qid)
|
||||
tx_ring->tx_buffer_info[i].dmamap);
|
||||
|
||||
#ifdef DEV_NETMAP
|
||||
if (adapter->ifp->if_capenable & IFCAP_NETMAP) {
|
||||
if (if_getcapenable(adapter->ifp) & IFCAP_NETMAP) {
|
||||
nm_info = &tx_ring->tx_buffer_info[i].nm_info;
|
||||
for (j = 0; j < ENA_PKT_MAX_BUFS; j++) {
|
||||
if (nm_info->socket_buf_idx[j] != 0) {
|
||||
@ -882,7 +882,7 @@ ena_setup_rx_resources(struct ena_adapter *adapter, unsigned int qid)
|
||||
}
|
||||
|
||||
/* Create LRO for the ring */
|
||||
if ((adapter->ifp->if_capenable & IFCAP_LRO) != 0) {
|
||||
if ((if_getcapenable(adapter->ifp) & IFCAP_LRO) != 0) {
|
||||
int err = tcp_lro_init(&rx_ring->lro);
|
||||
if (err != 0) {
|
||||
ena_log(pdev, ERR, "LRO[%d] Initialization failed!\n",
|
||||
@ -1292,7 +1292,7 @@ ena_free_rx_bufs(struct ena_adapter *adapter, unsigned int qid)
|
||||
ena_free_rx_mbuf(adapter, rx_ring, rx_info);
|
||||
#ifdef DEV_NETMAP
|
||||
if (((if_getflags(adapter->ifp) & IFF_DYING) == 0) &&
|
||||
(adapter->ifp->if_capenable & IFCAP_NETMAP)) {
|
||||
(if_getcapenable(adapter->ifp) & IFCAP_NETMAP)) {
|
||||
if (rx_info->netmap_buf_idx != 0)
|
||||
ena_netmap_free_rx_slot(adapter, rx_ring,
|
||||
rx_info);
|
||||
@ -1964,7 +1964,7 @@ ena_up_complete(struct ena_adapter *adapter)
|
||||
}
|
||||
}
|
||||
|
||||
rc = ena_change_mtu(adapter->ifp, adapter->ifp->if_mtu);
|
||||
rc = ena_change_mtu(adapter->ifp, if_getmtu(adapter->ifp));
|
||||
if (unlikely(rc != 0))
|
||||
return (rc);
|
||||
|
||||
@ -2225,7 +2225,7 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data)
|
||||
struct ifreq *ifr;
|
||||
int rc;
|
||||
|
||||
adapter = ifp->if_softc;
|
||||
adapter = if_getsoftc(ifp);
|
||||
ifr = (struct ifreq *)data;
|
||||
|
||||
/*
|
||||
@ -2234,7 +2234,7 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data)
|
||||
rc = 0;
|
||||
switch (command) {
|
||||
case SIOCSIFMTU:
|
||||
if (ifp->if_mtu == ifr->ifr_mtu)
|
||||
if (if_getmtu(ifp) == ifr->ifr_mtu)
|
||||
break;
|
||||
ENA_LOCK_LOCK();
|
||||
ena_down(adapter);
|
||||
@ -2246,10 +2246,10 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data)
|
||||
break;
|
||||
|
||||
case SIOCSIFFLAGS:
|
||||
if ((ifp->if_flags & IFF_UP) != 0) {
|
||||
if ((if_getflags(ifp) & IFF_UP) != 0) {
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
|
||||
if ((ifp->if_flags &
|
||||
(IFF_PROMISC | IFF_ALLMULTI)) != 0) {
|
||||
if ((if_getflags(ifp) & (IFF_PROMISC |
|
||||
IFF_ALLMULTI)) != 0) {
|
||||
ena_log(adapter->pdev, INFO,
|
||||
"ioctl promisc/allmulti\n");
|
||||
}
|
||||
@ -2280,8 +2280,8 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data)
|
||||
{
|
||||
int reinit = 0;
|
||||
|
||||
if (ifr->ifr_reqcap != ifp->if_capenable) {
|
||||
ifp->if_capenable = ifr->ifr_reqcap;
|
||||
if (ifr->ifr_reqcap != if_getcapenable(ifp)) {
|
||||
if_setcapenable(ifp, ifr->ifr_reqcap);
|
||||
reinit = 1;
|
||||
}
|
||||
|
||||
@ -2414,10 +2414,10 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter,
|
||||
if_setcapabilitiesbit(ifp, caps, 0);
|
||||
|
||||
/* TSO parameters */
|
||||
ifp->if_hw_tsomax = ENA_TSO_MAXSIZE -
|
||||
(ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
|
||||
ifp->if_hw_tsomaxsegcount = adapter->max_tx_sgl_size - 1;
|
||||
ifp->if_hw_tsomaxsegsize = ENA_TSO_MAXSIZE;
|
||||
if_sethwtsomax(ifp, ENA_TSO_MAXSIZE -
|
||||
(ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN));
|
||||
if_sethwtsomaxsegcount(ifp, adapter->max_tx_sgl_size - 1);
|
||||
if_sethwtsomaxsegsize(ifp, ENA_TSO_MAXSIZE);
|
||||
|
||||
if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
|
||||
if_setcapenable(ifp, if_getcapabilities(ifp));
|
||||
@ -3744,7 +3744,7 @@ ena_detach(device_t pdev)
|
||||
int rc;
|
||||
|
||||
/* Make sure VLANS are not using driver */
|
||||
if (adapter->ifp->if_vlantrunk != NULL) {
|
||||
if (if_vlantrunkinuse(adapter->ifp)) {
|
||||
ena_log(adapter->pdev, ERR, "VLAN is in use, detach first\n");
|
||||
return (EBUSY);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ void
|
||||
ena_deferred_mq_start(void *arg, int pending)
|
||||
{
|
||||
struct ena_ring *tx_ring = (struct ena_ring *)arg;
|
||||
struct ifnet *ifp = tx_ring->adapter->ifp;
|
||||
if_t ifp = tx_ring->adapter->ifp;
|
||||
|
||||
while (!drbr_empty(ifp, tx_ring->br) && tx_ring->running &&
|
||||
(if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
|
||||
@ -128,7 +128,7 @@ ena_deferred_mq_start(void *arg, int pending)
|
||||
int
|
||||
ena_mq_start(if_t ifp, struct mbuf *m)
|
||||
{
|
||||
struct ena_adapter *adapter = ifp->if_softc;
|
||||
struct ena_adapter *adapter = if_getsoftc(ifp);
|
||||
struct ena_ring *tx_ring;
|
||||
int ret, is_drbr_empty;
|
||||
uint32_t i;
|
||||
@ -179,7 +179,7 @@ ena_mq_start(if_t ifp, struct mbuf *m)
|
||||
void
|
||||
ena_qflush(if_t ifp)
|
||||
{
|
||||
struct ena_adapter *adapter = ifp->if_softc;
|
||||
struct ena_adapter *adapter = if_getsoftc(ifp);
|
||||
struct ena_ring *tx_ring = adapter->tx_ring;
|
||||
int i;
|
||||
|
||||
@ -643,8 +643,8 @@ ena_rx_cleanup(struct ena_ring *rx_ring)
|
||||
break;
|
||||
}
|
||||
|
||||
if (((ifp->if_capenable & IFCAP_RXCSUM) != 0) ||
|
||||
((ifp->if_capenable & IFCAP_RXCSUM_IPV6) != 0)) {
|
||||
if (((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0) ||
|
||||
((if_getcapenable(ifp) & IFCAP_RXCSUM_IPV6) != 0)) {
|
||||
ena_rx_checksum(rx_ring, &ena_rx_ctx, mbuf);
|
||||
}
|
||||
|
||||
@ -659,7 +659,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring)
|
||||
* should be computed by hardware.
|
||||
*/
|
||||
do_if_input = 1;
|
||||
if (((ifp->if_capenable & IFCAP_LRO) != 0) &&
|
||||
if (((if_getcapenable(ifp) & IFCAP_LRO) != 0) &&
|
||||
((mbuf->m_pkthdr.csum_flags & CSUM_IP_VALID) != 0) &&
|
||||
(ena_rx_ctx.l4_proto == ENA_ETH_IO_L4_PROTO_TCP)) {
|
||||
/*
|
||||
@ -675,7 +675,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring)
|
||||
if (do_if_input != 0) {
|
||||
ena_log_io(pdev, DBG,
|
||||
"calling if_input() with mbuf %p\n", mbuf);
|
||||
(*ifp->if_input)(ifp, mbuf);
|
||||
if_input(ifp, mbuf);
|
||||
}
|
||||
|
||||
counter_enter();
|
||||
|
@ -224,7 +224,7 @@ ena_ring_in_netmap(struct ena_adapter *adapter, int qid, enum txrx x)
|
||||
struct netmap_adapter *na;
|
||||
struct netmap_kring *kring;
|
||||
|
||||
if (adapter->ifp->if_capenable & IFCAP_NETMAP) {
|
||||
if (if_getcapenable(adapter->ifp) & IFCAP_NETMAP) {
|
||||
na = NA(adapter->ifp);
|
||||
kring = (x == NR_RX) ? na->rx_rings[qid] : na->tx_rings[qid];
|
||||
if (kring->nr_mode == NKR_NETMAP_ON)
|
||||
@ -271,8 +271,8 @@ ena_netmap_reset_tx_ring(struct ena_adapter *adapter, int qid)
|
||||
static int
|
||||
ena_netmap_reg(struct netmap_adapter *na, int onoff)
|
||||
{
|
||||
struct ifnet *ifp = na->ifp;
|
||||
struct ena_adapter *adapter = ifp->if_softc;
|
||||
if_t ifp = na->ifp;
|
||||
struct ena_adapter *adapter = if_getsoftc(ifp);
|
||||
device_t pdev = adapter->pdev;
|
||||
struct netmap_kring *kring;
|
||||
enum txrx t;
|
||||
@ -528,7 +528,7 @@ ena_netmap_map_single_slot(struct netmap_adapter *na, struct netmap_slot *slot,
|
||||
device_t pdev;
|
||||
int rc;
|
||||
|
||||
pdev = ((struct ena_adapter *)na->ifp->if_softc)->pdev;
|
||||
pdev = ((struct ena_adapter *)if_getsoftc(na->ifp))->pdev;
|
||||
|
||||
*vaddr = PNMB(na, slot, paddr);
|
||||
if (unlikely(vaddr == NULL)) {
|
||||
@ -1065,7 +1065,7 @@ ena_netmap_fill_ctx(struct netmap_kring *kring, struct ena_netmap_ctx *ctx,
|
||||
{
|
||||
ctx->kring = kring;
|
||||
ctx->na = kring->na;
|
||||
ctx->adapter = ctx->na->ifp->if_softc;
|
||||
ctx->adapter = if_getsoftc(ctx->na->ifp);
|
||||
ctx->lim = kring->nkr_num_slots - 1;
|
||||
ctx->io_cq = &ctx->adapter->ena_dev->io_cq_queues[ena_qid];
|
||||
ctx->io_sq = &ctx->adapter->ena_dev->io_sq_queues[ena_qid];
|
||||
|
Loading…
Reference in New Issue
Block a user