Commit 9ba095a6 authored by Jan Sokolowski's avatar Jan Sokolowski Committed by Jeff Kirsher

ixgbe: remove umem from adapter

As current implementation of netdev already contains and provides
umems for us, we no longer have the need to contain these
structures in ixgbe_adapter.

Refactor the code to operate on netdev-provided umems.
Signed-off-by: default avatarJan Sokolowski <jan.sokolowski@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent d49e286d
...@@ -775,11 +775,6 @@ struct ixgbe_adapter { ...@@ -775,11 +775,6 @@ struct ixgbe_adapter {
#ifdef CONFIG_IXGBE_IPSEC #ifdef CONFIG_IXGBE_IPSEC
struct ixgbe_ipsec *ipsec; struct ixgbe_ipsec *ipsec;
#endif /* CONFIG_IXGBE_IPSEC */ #endif /* CONFIG_IXGBE_IPSEC */
/* AF_XDP zero-copy */
struct xdp_umem **xsk_umems;
u16 num_xsk_umems_used;
u16 num_xsk_umems;
}; };
static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter) static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter)
...@@ -1040,4 +1035,10 @@ static inline int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, ...@@ -1040,4 +1035,10 @@ static inline int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter,
static inline int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter, static inline int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter,
u32 *mbuf, u32 vf) { return -EACCES; } u32 *mbuf, u32 vf) { return -EACCES; }
#endif /* CONFIG_IXGBE_IPSEC */ #endif /* CONFIG_IXGBE_IPSEC */
static inline bool ixgbe_enabled_xdp_adapter(struct ixgbe_adapter *adapter)
{
return !!adapter->xdp_prog;
}
#endif /* _IXGBE_H_ */ #endif /* _IXGBE_H_ */
...@@ -14,58 +14,10 @@ struct xdp_umem *ixgbe_xsk_umem(struct ixgbe_adapter *adapter, ...@@ -14,58 +14,10 @@ struct xdp_umem *ixgbe_xsk_umem(struct ixgbe_adapter *adapter,
bool xdp_on = READ_ONCE(adapter->xdp_prog); bool xdp_on = READ_ONCE(adapter->xdp_prog);
int qid = ring->ring_idx; int qid = ring->ring_idx;
if (!adapter->xsk_umems || !adapter->xsk_umems[qid] || if (!xdp_on || !test_bit(qid, adapter->af_xdp_zc_qps))
qid >= adapter->num_xsk_umems || !xdp_on ||
!test_bit(qid, adapter->af_xdp_zc_qps))
return NULL; return NULL;
return adapter->xsk_umems[qid]; return xdp_get_umem_from_qid(adapter->netdev, qid);
}
static int ixgbe_alloc_xsk_umems(struct ixgbe_adapter *adapter)
{
if (adapter->xsk_umems)
return 0;
adapter->num_xsk_umems_used = 0;
adapter->num_xsk_umems = adapter->num_rx_queues;
adapter->xsk_umems = kcalloc(adapter->num_xsk_umems,
sizeof(*adapter->xsk_umems),
GFP_KERNEL);
if (!adapter->xsk_umems) {
adapter->num_xsk_umems = 0;
return -ENOMEM;
}
return 0;
}
static int ixgbe_add_xsk_umem(struct ixgbe_adapter *adapter,
struct xdp_umem *umem,
u16 qid)
{
int err;
err = ixgbe_alloc_xsk_umems(adapter);
if (err)
return err;
adapter->xsk_umems[qid] = umem;
adapter->num_xsk_umems_used++;
return 0;
}
static void ixgbe_remove_xsk_umem(struct ixgbe_adapter *adapter, u16 qid)
{
adapter->xsk_umems[qid] = NULL;
adapter->num_xsk_umems_used--;
if (adapter->num_xsk_umems == 0) {
kfree(adapter->xsk_umems);
adapter->xsk_umems = NULL;
adapter->num_xsk_umems = 0;
}
} }
static int ixgbe_xsk_umem_dma_map(struct ixgbe_adapter *adapter, static int ixgbe_xsk_umem_dma_map(struct ixgbe_adapter *adapter,
...@@ -114,6 +66,7 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter, ...@@ -114,6 +66,7 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter,
struct xdp_umem *umem, struct xdp_umem *umem,
u16 qid) u16 qid)
{ {
struct net_device *netdev = adapter->netdev;
struct xdp_umem_fq_reuse *reuseq; struct xdp_umem_fq_reuse *reuseq;
bool if_running; bool if_running;
int err; int err;
...@@ -121,12 +74,9 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter, ...@@ -121,12 +74,9 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter,
if (qid >= adapter->num_rx_queues) if (qid >= adapter->num_rx_queues)
return -EINVAL; return -EINVAL;
if (adapter->xsk_umems) { if (qid >= netdev->real_num_rx_queues ||
if (qid >= adapter->num_xsk_umems) qid >= netdev->real_num_tx_queues)
return -EINVAL; return -EINVAL;
if (adapter->xsk_umems[qid])
return -EBUSY;
}
reuseq = xsk_reuseq_prepare(adapter->rx_ring[0]->count); reuseq = xsk_reuseq_prepare(adapter->rx_ring[0]->count);
if (!reuseq) if (!reuseq)
...@@ -139,15 +89,12 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter, ...@@ -139,15 +89,12 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter,
return err; return err;
if_running = netif_running(adapter->netdev) && if_running = netif_running(adapter->netdev) &&
READ_ONCE(adapter->xdp_prog); ixgbe_enabled_xdp_adapter(adapter);
if (if_running) if (if_running)
ixgbe_txrx_ring_disable(adapter, qid); ixgbe_txrx_ring_disable(adapter, qid);
set_bit(qid, adapter->af_xdp_zc_qps); set_bit(qid, adapter->af_xdp_zc_qps);
err = ixgbe_add_xsk_umem(adapter, umem, qid);
if (err)
return err;
if (if_running) { if (if_running) {
ixgbe_txrx_ring_enable(adapter, qid); ixgbe_txrx_ring_enable(adapter, qid);
...@@ -163,21 +110,21 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter, ...@@ -163,21 +110,21 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter,
static int ixgbe_xsk_umem_disable(struct ixgbe_adapter *adapter, u16 qid) static int ixgbe_xsk_umem_disable(struct ixgbe_adapter *adapter, u16 qid)
{ {
struct xdp_umem *umem;
bool if_running; bool if_running;
if (!adapter->xsk_umems || qid >= adapter->num_xsk_umems || umem = xdp_get_umem_from_qid(adapter->netdev, qid);
!adapter->xsk_umems[qid]) if (!umem)
return -EINVAL; return -EINVAL;
if_running = netif_running(adapter->netdev) && if_running = netif_running(adapter->netdev) &&
READ_ONCE(adapter->xdp_prog); ixgbe_enabled_xdp_adapter(adapter);
if (if_running) if (if_running)
ixgbe_txrx_ring_disable(adapter, qid); ixgbe_txrx_ring_disable(adapter, qid);
clear_bit(qid, adapter->af_xdp_zc_qps); clear_bit(qid, adapter->af_xdp_zc_qps);
ixgbe_xsk_umem_dma_unmap(adapter, adapter->xsk_umems[qid]); ixgbe_xsk_umem_dma_unmap(adapter, umem);
ixgbe_remove_xsk_umem(adapter, qid);
if (if_running) if (if_running)
ixgbe_txrx_ring_enable(adapter, qid); ixgbe_txrx_ring_enable(adapter, qid);
...@@ -756,7 +703,7 @@ int ixgbe_xsk_async_xmit(struct net_device *dev, u32 qid) ...@@ -756,7 +703,7 @@ int ixgbe_xsk_async_xmit(struct net_device *dev, u32 qid)
if (qid >= adapter->num_xdp_queues) if (qid >= adapter->num_xdp_queues)
return -ENXIO; return -ENXIO;
if (!adapter->xsk_umems || !adapter->xsk_umems[qid]) if (!adapter->xdp_ring[qid]->xsk_umem)
return -ENXIO; return -ENXIO;
ring = adapter->xdp_ring[qid]; ring = adapter->xdp_ring[qid];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment