Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /****************************************************************************
0003  * Driver for Solarflare network controllers and boards
0004  * Copyright 2018 Solarflare Communications Inc.
0005  *
0006  * This program is free software; you can redistribute it and/or modify it
0007  * under the terms of the GNU General Public License version 2 as published
0008  * by the Free Software Foundation, incorporated herein by reference.
0009  */
0010 
0011 #ifndef EFX_RX_COMMON_H
0012 #define EFX_RX_COMMON_H
0013 
0014 /* Preferred number of descriptors to fill at once */
0015 #define EFX_RX_PREFERRED_BATCH 8U
0016 
0017 /* Each packet can consume up to ceil(max_frame_len / buffer_size) buffers */
0018 #define EFX_RX_MAX_FRAGS DIV_ROUND_UP(EFX_MAX_FRAME_LEN(EFX_MAX_MTU), \
0019                       EFX_RX_USR_BUF_SIZE)
0020 
0021 /* Number of RX buffers to recycle pages for.  When creating the RX page recycle
0022  * ring, this number is divided by the number of buffers per page to calculate
0023  * the number of pages to store in the RX page recycle ring.
0024  */
0025 #define EFX_RECYCLE_RING_SIZE_10G   256
0026 
0027 static inline u8 *efx_rx_buf_va(struct efx_rx_buffer *buf)
0028 {
0029     return page_address(buf->page) + buf->page_offset;
0030 }
0031 
0032 static inline u32 efx_rx_buf_hash(struct efx_nic *efx, const u8 *eh)
0033 {
0034 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
0035     return __le32_to_cpup((const __le32 *)(eh + efx->rx_packet_hash_offset));
0036 #else
0037     const u8 *data = eh + efx->rx_packet_hash_offset;
0038 
0039     return (u32)data[0]   |
0040            (u32)data[1] << 8  |
0041            (u32)data[2] << 16 |
0042            (u32)data[3] << 24;
0043 #endif
0044 }
0045 
0046 void efx_rx_slow_fill(struct timer_list *t);
0047 
0048 void efx_recycle_rx_pages(struct efx_channel *channel,
0049               struct efx_rx_buffer *rx_buf,
0050               unsigned int n_frags);
0051 void efx_discard_rx_packet(struct efx_channel *channel,
0052                struct efx_rx_buffer *rx_buf,
0053                unsigned int n_frags);
0054 
0055 int efx_probe_rx_queue(struct efx_rx_queue *rx_queue);
0056 void efx_init_rx_queue(struct efx_rx_queue *rx_queue);
0057 void efx_fini_rx_queue(struct efx_rx_queue *rx_queue);
0058 void efx_remove_rx_queue(struct efx_rx_queue *rx_queue);
0059 void efx_destroy_rx_queue(struct efx_rx_queue *rx_queue);
0060 
0061 void efx_init_rx_buffer(struct efx_rx_queue *rx_queue,
0062             struct page *page,
0063             unsigned int page_offset,
0064             u16 flags);
0065 void efx_unmap_rx_buffer(struct efx_nic *efx, struct efx_rx_buffer *rx_buf);
0066 
0067 static inline void efx_sync_rx_buffer(struct efx_nic *efx,
0068                       struct efx_rx_buffer *rx_buf,
0069                       unsigned int len)
0070 {
0071     dma_sync_single_for_cpu(&efx->pci_dev->dev, rx_buf->dma_addr, len,
0072                 DMA_FROM_DEVICE);
0073 }
0074 
0075 void efx_free_rx_buffers(struct efx_rx_queue *rx_queue,
0076              struct efx_rx_buffer *rx_buf,
0077              unsigned int num_bufs);
0078 
0079 void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue);
0080 void efx_rx_config_page_split(struct efx_nic *efx);
0081 void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue, bool atomic);
0082 
0083 void
0084 efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf,
0085           unsigned int n_frags, u8 *eh, __wsum csum);
0086 
0087 struct efx_rss_context *efx_alloc_rss_context_entry(struct efx_nic *efx);
0088 struct efx_rss_context *efx_find_rss_context_entry(struct efx_nic *efx, u32 id);
0089 void efx_free_rss_context_entry(struct efx_rss_context *ctx);
0090 void efx_set_default_rx_indir_table(struct efx_nic *efx,
0091                     struct efx_rss_context *ctx);
0092 
0093 bool efx_filter_is_mc_recipient(const struct efx_filter_spec *spec);
0094 bool efx_filter_spec_equal(const struct efx_filter_spec *left,
0095                const struct efx_filter_spec *right);
0096 u32 efx_filter_spec_hash(const struct efx_filter_spec *spec);
0097 
0098 #ifdef CONFIG_RFS_ACCEL
0099 bool efx_rps_check_rule(struct efx_arfs_rule *rule, unsigned int filter_idx,
0100             bool *force);
0101 struct efx_arfs_rule *efx_rps_hash_find(struct efx_nic *efx,
0102                     const struct efx_filter_spec *spec);
0103 struct efx_arfs_rule *efx_rps_hash_add(struct efx_nic *efx,
0104                        const struct efx_filter_spec *spec,
0105                        bool *new);
0106 void efx_rps_hash_del(struct efx_nic *efx, const struct efx_filter_spec *spec);
0107 
0108 int efx_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
0109            u16 rxq_index, u32 flow_id);
0110 bool __efx_filter_rfs_expire(struct efx_channel *channel, unsigned int quota);
0111 #endif
0112 
0113 int efx_probe_filters(struct efx_nic *efx);
0114 void efx_remove_filters(struct efx_nic *efx);
0115 
0116 #endif