1818#include <linux/i2c-algo-bit.h>
1919#include <linux/pci.h>
2020#include <linux/mdio.h>
21+ #include <linux/lockdep.h>
2122
2223#include <net/xdp.h>
24+ #include <net/xdp_sock_drv.h>
2325
2426struct igb_adapter ;
2527
@@ -86,6 +88,7 @@ struct igb_adapter;
8688#define IGB_XDP_CONSUMED BIT(0)
8789#define IGB_XDP_TX BIT(1)
8890#define IGB_XDP_REDIR BIT(2)
91+ #define IGB_XDP_EXIT BIT(3)
8992
9093struct vf_data_storage {
9194 unsigned char vf_mac_addresses [ETH_ALEN ];
@@ -255,6 +258,7 @@ enum igb_tx_flags {
255258enum igb_tx_buf_type {
256259 IGB_TYPE_SKB = 0 ,
257260 IGB_TYPE_XDP ,
261+ IGB_TYPE_XSK
258262};
259263
260264/* wrapper around a pointer to a socket buffer,
@@ -320,6 +324,7 @@ struct igb_ring {
320324 union { /* array of buffer info structs */
321325 struct igb_tx_buffer * tx_buffer_info ;
322326 struct igb_rx_buffer * rx_buffer_info ;
327+ struct xdp_buff * * rx_buffer_info_zc ;
323328 };
324329 void * desc ; /* descriptor ring memory */
325330 unsigned long flags ; /* ring specific flags */
@@ -357,6 +362,7 @@ struct igb_ring {
357362 };
358363 };
359364 struct xdp_rxq_info xdp_rxq ;
365+ struct xsk_buff_pool * xsk_pool ;
360366} ____cacheline_internodealigned_in_smp ;
361367
362368struct igb_q_vector {
@@ -384,7 +390,9 @@ enum e1000_ring_flags_t {
384390 IGB_RING_FLAG_RX_SCTP_CSUM ,
385391 IGB_RING_FLAG_RX_LB_VLAN_BSWAP ,
386392 IGB_RING_FLAG_TX_CTX_IDX ,
387- IGB_RING_FLAG_TX_DETECT_HANG
393+ IGB_RING_FLAG_TX_DETECT_HANG ,
394+ IGB_RING_FLAG_TX_DISABLED ,
395+ IGB_RING_FLAG_RX_ALLOC_FAILED ,
388396};
389397
390398#define ring_uses_large_buffer (ring ) \
@@ -715,6 +723,8 @@ enum igb_boards {
715723
716724extern char igb_driver_name [];
717725
726+ void igb_set_queue_napi (struct igb_adapter * adapter , int q_idx ,
727+ struct napi_struct * napi );
718728int igb_xmit_xdp_ring (struct igb_adapter * adapter ,
719729 struct igb_ring * ring ,
720730 struct xdp_frame * xdpf );
@@ -731,12 +741,21 @@ int igb_setup_tx_resources(struct igb_ring *);
731741int igb_setup_rx_resources (struct igb_ring * );
732742void igb_free_tx_resources (struct igb_ring * );
733743void igb_free_rx_resources (struct igb_ring * );
744+ void igb_clean_tx_ring (struct igb_ring * tx_ring );
745+ void igb_clean_rx_ring (struct igb_ring * rx_ring );
734746void igb_configure_tx_ring (struct igb_adapter * , struct igb_ring * );
735747void igb_configure_rx_ring (struct igb_adapter * , struct igb_ring * );
748+ void igb_finalize_xdp (struct igb_adapter * adapter , unsigned int status );
749+ void igb_update_rx_stats (struct igb_q_vector * q_vector , unsigned int packets ,
750+ unsigned int bytes );
736751void igb_setup_tctl (struct igb_adapter * );
737752void igb_setup_rctl (struct igb_adapter * );
738753void igb_setup_srrctl (struct igb_adapter * , struct igb_ring * );
739754netdev_tx_t igb_xmit_frame_ring (struct sk_buff * , struct igb_ring * );
755+ int igb_xdp_xmit_back (struct igb_adapter * adapter , struct xdp_buff * xdp );
756+ void igb_process_skb_fields (struct igb_ring * rx_ring ,
757+ union e1000_adv_rx_desc * rx_desc ,
758+ struct sk_buff * skb );
740759void igb_alloc_rx_buffers (struct igb_ring * , u16 );
741760void igb_update_stats (struct igb_adapter * );
742761bool igb_has_link (struct igb_adapter * adapter );
@@ -797,6 +816,33 @@ static inline struct netdev_queue *txring_txq(const struct igb_ring *tx_ring)
797816 return netdev_get_tx_queue (tx_ring -> netdev , tx_ring -> queue_index );
798817}
799818
819+ /* This function assumes __netif_tx_lock is held by the caller. */
820+ static inline void igb_xdp_ring_update_tail (struct igb_ring * ring )
821+ {
822+ lockdep_assert_held (& txring_txq (ring )-> _xmit_lock );
823+
824+ /* Force memory writes to complete before letting h/w know there
825+ * are new descriptors to fetch.
826+ */
827+ wmb ();
828+ writel (ring -> next_to_use , ring -> tail );
829+ }
830+
831+ static inline struct igb_ring * igb_xdp_tx_queue_mapping (struct igb_adapter * adapter )
832+ {
833+ unsigned int r_idx = smp_processor_id ();
834+
835+ if (r_idx >= adapter -> num_tx_queues )
836+ r_idx = r_idx % adapter -> num_tx_queues ;
837+
838+ return adapter -> tx_ring [r_idx ];
839+ }
840+
841+ static inline bool igb_xdp_is_enabled (struct igb_adapter * adapter )
842+ {
843+ return !!READ_ONCE (adapter -> xdp_prog );
844+ }
845+
800846int igb_add_filter (struct igb_adapter * adapter ,
801847 struct igb_nfc_filter * input );
802848int igb_erase_filter (struct igb_adapter * adapter ,
@@ -807,4 +853,17 @@ int igb_add_mac_steering_filter(struct igb_adapter *adapter,
807853int igb_del_mac_steering_filter (struct igb_adapter * adapter ,
808854 const u8 * addr , u8 queue , u8 flags );
809855
856+ struct xsk_buff_pool * igb_xsk_pool (struct igb_adapter * adapter ,
857+ struct igb_ring * ring );
858+ int igb_xsk_pool_setup (struct igb_adapter * adapter ,
859+ struct xsk_buff_pool * pool ,
860+ u16 qid );
861+ bool igb_alloc_rx_buffers_zc (struct igb_ring * rx_ring ,
862+ struct xsk_buff_pool * xsk_pool , u16 count );
863+ void igb_clean_rx_ring_zc (struct igb_ring * rx_ring );
864+ int igb_clean_rx_irq_zc (struct igb_q_vector * q_vector ,
865+ struct xsk_buff_pool * xsk_pool , const int budget );
866+ bool igb_xmit_zc (struct igb_ring * tx_ring , struct xsk_buff_pool * xsk_pool );
867+ int igb_xsk_wakeup (struct net_device * dev , u32 qid , u32 flags );
868+
810869#endif /* _IGB_H_ */
0 commit comments