1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2018 Solarflare Communications Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
11 #ifndef EFX_RX_COMMON_H
12 #define EFX_RX_COMMON_H
14 /* Preferred number of descriptors to fill at once */
15 #define EFX_RX_PREFERRED_BATCH 8U
17 /* Each packet can consume up to ceil(max_frame_len / buffer_size) buffers */
18 #define EFX_RX_MAX_FRAGS DIV_ROUND_UP(EFX_MAX_FRAME_LEN(EFX_MAX_MTU), \
21 static inline u8
*efx_rx_buf_va(struct efx_rx_buffer
*buf
)
23 return page_address(buf
->page
) + buf
->page_offset
;
26 static inline u32
efx_rx_buf_hash(struct efx_nic
*efx
, const u8
*eh
)
28 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
29 return __le32_to_cpup((const __le32
*)(eh
+ efx
->rx_packet_hash_offset
));
31 const u8
*data
= eh
+ efx
->rx_packet_hash_offset
;
40 void efx_rx_slow_fill(struct timer_list
*t
);
42 void efx_recycle_rx_pages(struct efx_channel
*channel
,
43 struct efx_rx_buffer
*rx_buf
,
44 unsigned int n_frags
);
45 void efx_discard_rx_packet(struct efx_channel
*channel
,
46 struct efx_rx_buffer
*rx_buf
,
47 unsigned int n_frags
);
49 int efx_probe_rx_queue(struct efx_rx_queue
*rx_queue
);
50 void efx_init_rx_queue(struct efx_rx_queue
*rx_queue
);
51 void efx_fini_rx_queue(struct efx_rx_queue
*rx_queue
);
52 void efx_remove_rx_queue(struct efx_rx_queue
*rx_queue
);
53 void efx_destroy_rx_queue(struct efx_rx_queue
*rx_queue
);
55 void efx_init_rx_buffer(struct efx_rx_queue
*rx_queue
,
57 unsigned int page_offset
,
59 void efx_unmap_rx_buffer(struct efx_nic
*efx
, struct efx_rx_buffer
*rx_buf
);
60 void efx_free_rx_buffers(struct efx_rx_queue
*rx_queue
,
61 struct efx_rx_buffer
*rx_buf
,
62 unsigned int num_bufs
);
64 void efx_schedule_slow_fill(struct efx_rx_queue
*rx_queue
);
65 void efx_rx_config_page_split(struct efx_nic
*efx
);
66 void efx_fast_push_rx_descriptors(struct efx_rx_queue
*rx_queue
, bool atomic
);
69 efx_rx_packet_gro(struct efx_channel
*channel
, struct efx_rx_buffer
*rx_buf
,
70 unsigned int n_frags
, u8
*eh
);
72 struct efx_rss_context
*efx_alloc_rss_context_entry(struct efx_nic
*efx
);
73 struct efx_rss_context
*efx_find_rss_context_entry(struct efx_nic
*efx
, u32 id
);
74 void efx_free_rss_context_entry(struct efx_rss_context
*ctx
);
75 void efx_set_default_rx_indir_table(struct efx_nic
*efx
,
76 struct efx_rss_context
*ctx
);
78 bool efx_filter_is_mc_recipient(const struct efx_filter_spec
*spec
);
79 bool efx_filter_spec_equal(const struct efx_filter_spec
*left
,
80 const struct efx_filter_spec
*right
);
81 u32
efx_filter_spec_hash(const struct efx_filter_spec
*spec
);
83 #ifdef CONFIG_RFS_ACCEL
84 bool efx_rps_check_rule(struct efx_arfs_rule
*rule
, unsigned int filter_idx
,
86 struct efx_arfs_rule
*efx_rps_hash_find(struct efx_nic
*efx
,
87 const struct efx_filter_spec
*spec
);
88 struct efx_arfs_rule
*efx_rps_hash_add(struct efx_nic
*efx
,
89 const struct efx_filter_spec
*spec
,
91 void efx_rps_hash_del(struct efx_nic
*efx
, const struct efx_filter_spec
*spec
);
94 int efx_probe_filters(struct efx_nic
*efx
);
95 void efx_remove_filters(struct efx_nic
*efx
);