1e1253f39SAlex Maftei (amaftei) /* SPDX-License-Identifier: GPL-2.0-only */ 2e1253f39SAlex Maftei (amaftei) /**************************************************************************** 3e1253f39SAlex Maftei (amaftei) * Driver for Solarflare network controllers and boards 4e1253f39SAlex Maftei (amaftei) * Copyright 2018 Solarflare Communications Inc. 5e1253f39SAlex Maftei (amaftei) * 6e1253f39SAlex Maftei (amaftei) * This program is free software; you can redistribute it and/or modify it 7e1253f39SAlex Maftei (amaftei) * under the terms of the GNU General Public License version 2 as published 8e1253f39SAlex Maftei (amaftei) * by the Free Software Foundation, incorporated herein by reference. 9e1253f39SAlex Maftei (amaftei) */ 10e1253f39SAlex Maftei (amaftei) 11e1253f39SAlex Maftei (amaftei) #ifndef EFX_RX_COMMON_H 12e1253f39SAlex Maftei (amaftei) #define EFX_RX_COMMON_H 13e1253f39SAlex Maftei (amaftei) 14e1253f39SAlex Maftei (amaftei) /* Preferred number of descriptors to fill at once */ 15e1253f39SAlex Maftei (amaftei) #define EFX_RX_PREFERRED_BATCH 8U 16e1253f39SAlex Maftei (amaftei) 17e1253f39SAlex Maftei (amaftei) /* Each packet can consume up to ceil(max_frame_len / buffer_size) buffers */ 18e1253f39SAlex Maftei (amaftei) #define EFX_RX_MAX_FRAGS DIV_ROUND_UP(EFX_MAX_FRAME_LEN(EFX_MAX_MTU), \ 19e1253f39SAlex Maftei (amaftei) EFX_RX_USR_BUF_SIZE) 20e1253f39SAlex Maftei (amaftei) 213d95b884SAlex Maftei (amaftei) static inline u8 *efx_rx_buf_va(struct efx_rx_buffer *buf) 223d95b884SAlex Maftei (amaftei) { 233d95b884SAlex Maftei (amaftei) return page_address(buf->page) + buf->page_offset; 243d95b884SAlex Maftei (amaftei) } 253d95b884SAlex Maftei (amaftei) 263d95b884SAlex Maftei (amaftei) static inline u32 efx_rx_buf_hash(struct efx_nic *efx, const u8 *eh) 273d95b884SAlex Maftei (amaftei) { 283d95b884SAlex Maftei (amaftei) #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) 293d95b884SAlex Maftei (amaftei) return __le32_to_cpup((const __le32 *)(eh + efx->rx_packet_hash_offset)); 303d95b884SAlex Maftei (amaftei) #else 313d95b884SAlex Maftei (amaftei) const u8 *data = eh + efx->rx_packet_hash_offset; 323d95b884SAlex Maftei (amaftei) 333d95b884SAlex Maftei (amaftei) return (u32)data[0] | 343d95b884SAlex Maftei (amaftei) (u32)data[1] << 8 | 353d95b884SAlex Maftei (amaftei) (u32)data[2] << 16 | 363d95b884SAlex Maftei (amaftei) (u32)data[3] << 24; 373d95b884SAlex Maftei (amaftei) #endif 383d95b884SAlex Maftei (amaftei) } 393d95b884SAlex Maftei (amaftei) 40e1253f39SAlex Maftei (amaftei) void efx_rx_slow_fill(struct timer_list *t); 41e1253f39SAlex Maftei (amaftei) 423d95b884SAlex Maftei (amaftei) void efx_recycle_rx_pages(struct efx_channel *channel, 433d95b884SAlex Maftei (amaftei) struct efx_rx_buffer *rx_buf, 443d95b884SAlex Maftei (amaftei) unsigned int n_frags); 453d95b884SAlex Maftei (amaftei) void efx_discard_rx_packet(struct efx_channel *channel, 463d95b884SAlex Maftei (amaftei) struct efx_rx_buffer *rx_buf, 473d95b884SAlex Maftei (amaftei) unsigned int n_frags); 483d95b884SAlex Maftei (amaftei) 49e1253f39SAlex Maftei (amaftei) int efx_probe_rx_queue(struct efx_rx_queue *rx_queue); 50e1253f39SAlex Maftei (amaftei) void efx_init_rx_queue(struct efx_rx_queue *rx_queue); 51e1253f39SAlex Maftei (amaftei) void efx_fini_rx_queue(struct efx_rx_queue *rx_queue); 52e1253f39SAlex Maftei (amaftei) void efx_remove_rx_queue(struct efx_rx_queue *rx_queue); 53e1253f39SAlex Maftei (amaftei) void efx_destroy_rx_queue(struct efx_rx_queue *rx_queue); 54e1253f39SAlex Maftei (amaftei) 55e1253f39SAlex Maftei (amaftei) void efx_init_rx_buffer(struct efx_rx_queue *rx_queue, 56e1253f39SAlex Maftei (amaftei) struct page *page, 57e1253f39SAlex Maftei (amaftei) unsigned int page_offset, 58e1253f39SAlex Maftei (amaftei) u16 flags); 59e1253f39SAlex Maftei (amaftei) void efx_unmap_rx_buffer(struct efx_nic *efx, struct efx_rx_buffer *rx_buf); 60e1253f39SAlex Maftei (amaftei) void efx_free_rx_buffers(struct efx_rx_queue *rx_queue, 61e1253f39SAlex Maftei (amaftei) struct efx_rx_buffer *rx_buf, 62e1253f39SAlex Maftei (amaftei) unsigned int num_bufs); 63e1253f39SAlex Maftei (amaftei) 64e1253f39SAlex Maftei (amaftei) void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue); 65e1253f39SAlex Maftei (amaftei) void efx_rx_config_page_split(struct efx_nic *efx); 66e1253f39SAlex Maftei (amaftei) void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue, bool atomic); 67e1253f39SAlex Maftei (amaftei) 683d95b884SAlex Maftei (amaftei) void 693d95b884SAlex Maftei (amaftei) efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf, 703d95b884SAlex Maftei (amaftei) unsigned int n_frags, u8 *eh); 71960f1627SAlex Maftei (amaftei) 72960f1627SAlex Maftei (amaftei) struct efx_rss_context *efx_alloc_rss_context_entry(struct efx_nic *efx); 73960f1627SAlex Maftei (amaftei) struct efx_rss_context *efx_find_rss_context_entry(struct efx_nic *efx, u32 id); 74960f1627SAlex Maftei (amaftei) void efx_free_rss_context_entry(struct efx_rss_context *ctx); 75960f1627SAlex Maftei (amaftei) void efx_set_default_rx_indir_table(struct efx_nic *efx, 76960f1627SAlex Maftei (amaftei) struct efx_rss_context *ctx); 77*f7226e0fSAlex Maftei (amaftei) 78*f7226e0fSAlex Maftei (amaftei) bool efx_filter_is_mc_recipient(const struct efx_filter_spec *spec); 79*f7226e0fSAlex Maftei (amaftei) bool efx_filter_spec_equal(const struct efx_filter_spec *left, 80*f7226e0fSAlex Maftei (amaftei) const struct efx_filter_spec *right); 81*f7226e0fSAlex Maftei (amaftei) u32 efx_filter_spec_hash(const struct efx_filter_spec *spec); 82*f7226e0fSAlex Maftei (amaftei) 83*f7226e0fSAlex Maftei (amaftei) #ifdef CONFIG_RFS_ACCEL 84*f7226e0fSAlex Maftei (amaftei) bool efx_rps_check_rule(struct efx_arfs_rule *rule, unsigned int filter_idx, 85*f7226e0fSAlex Maftei (amaftei) bool *force); 86*f7226e0fSAlex Maftei (amaftei) struct efx_arfs_rule *efx_rps_hash_find(struct efx_nic *efx, 87*f7226e0fSAlex Maftei (amaftei) const struct efx_filter_spec *spec); 88*f7226e0fSAlex Maftei (amaftei) struct efx_arfs_rule *efx_rps_hash_add(struct efx_nic *efx, 89*f7226e0fSAlex Maftei (amaftei) const struct efx_filter_spec *spec, 90*f7226e0fSAlex Maftei (amaftei) bool *new); 91*f7226e0fSAlex Maftei (amaftei) void efx_rps_hash_del(struct efx_nic *efx, const struct efx_filter_spec *spec); 92*f7226e0fSAlex Maftei (amaftei) #endif 93*f7226e0fSAlex Maftei (amaftei) 94*f7226e0fSAlex Maftei (amaftei) int efx_probe_filters(struct efx_nic *efx); 95*f7226e0fSAlex Maftei (amaftei) void efx_remove_filters(struct efx_nic *efx); 96*f7226e0fSAlex Maftei (amaftei) 97e1253f39SAlex Maftei (amaftei) #endif 98