Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/gve/gve.h
| Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
| #define GVE_TX_TIMEOUT_KICK_COOLDOWN_SEC \ | #define GVE_TX_TIMEOUT_KICK_COOLDOWN_SEC \ | ||||
| (2 * GVE_TX_TIMEOUT_CHECK_CADENCE_SEC * GVE_TX_TIMEOUT_MAX_TX_QUEUES) | (2 * GVE_TX_TIMEOUT_CHECK_CADENCE_SEC * GVE_TX_TIMEOUT_MAX_TX_QUEUES) | ||||
| #define GVE_TIMESTAMP_INVALID -1 | #define GVE_TIMESTAMP_INVALID -1 | ||||
| #define ADMINQ_SIZE PAGE_SIZE | #define ADMINQ_SIZE PAGE_SIZE | ||||
| #define GVE_DEFAULT_RX_BUFFER_SIZE 2048 | #define GVE_DEFAULT_RX_BUFFER_SIZE 2048 | ||||
| #define GVE_4K_RX_BUFFER_SIZE_DQO 4096 | |||||
| /* Each RX bounce buffer page can fit two packet buffers. */ | /* Each RX bounce buffer page can fit two packet buffers. */ | ||||
| #define GVE_DEFAULT_RX_BUFFER_OFFSET (PAGE_SIZE / 2) | #define GVE_DEFAULT_RX_BUFFER_OFFSET (PAGE_SIZE / 2) | ||||
| /* PTYPEs are always 10 bits. */ | /* PTYPEs are always 10 bits. */ | ||||
| #define GVE_NUM_PTYPES 1024 | #define GVE_NUM_PTYPES 1024 | ||||
| /* | /* | ||||
| * Number of descriptors per queue page list. | * Number of descriptors per queue page list. | ||||
| * Page count AKA QPL size can be derived by dividing the number of elements in | * Page count AKA QPL size can be derived by dividing the number of elements in | ||||
| * a page by the number of descriptors available. | * a page by the number of descriptors available. | ||||
| */ | */ | ||||
| #define GVE_QPL_DIVISOR 16 | #define GVE_QPL_DIVISOR 16 | ||||
| /* Ring Size Limits */ | /* Ring Size Limits */ | ||||
| #define GVE_DEFAULT_MIN_RX_RING_SIZE 512 | #define GVE_DEFAULT_MIN_RX_RING_SIZE 512 | ||||
| #define GVE_DEFAULT_MIN_TX_RING_SIZE 256 | #define GVE_DEFAULT_MIN_TX_RING_SIZE 256 | ||||
| static MALLOC_DEFINE(M_GVE, "gve", "gve allocations"); | static MALLOC_DEFINE(M_GVE, "gve", "gve allocations"); | ||||
| _Static_assert(MCLBYTES == GVE_DEFAULT_RX_BUFFER_SIZE, | |||||
| "gve: bad MCLBYTES length"); | |||||
| _Static_assert(MJUMPAGESIZE >= GVE_4K_RX_BUFFER_SIZE_DQO, | |||||
| "gve: bad MJUMPAGESIZE length"); | |||||
markj: Sorry, I realized that this will trivially fail on arm64 when the page size is 16KB. There, we… | |||||
Not Done Inline ActionsI committed a follow-up change to relax the assertion for the MCLBYTES comparison as well--there are some non-default kernel configs which set MCLBYTES=4096. In that case we don't have to switch allocation strategies, so the driver could be modified to handle it, but I'm not sure it's worth bothering. The kernel config in question changes the default only as a testing measure. markj: I committed a follow-up change to relax the assertion for the MCLBYTES comparison as well… | |||||
| struct gve_dma_handle { | struct gve_dma_handle { | ||||
| bus_addr_t bus_addr; | bus_addr_t bus_addr; | ||||
| void *cpu_addr; | void *cpu_addr; | ||||
| bus_dma_tag_t tag; | bus_dma_tag_t tag; | ||||
| bus_dmamap_t map; | bus_dmamap_t map; | ||||
| }; | }; | ||||
| union gve_tx_desc { | union gve_tx_desc { | ||||
| ▲ Show 20 Lines • Show All 533 Lines • ▼ Show 20 Lines | struct gve_priv { | ||||
| struct gve_state_flags state_flags; | struct gve_state_flags state_flags; | ||||
| struct sx gve_iface_lock; | struct sx gve_iface_lock; | ||||
| struct callout tx_timeout_service; | struct callout tx_timeout_service; | ||||
| /* The index of tx queue that the timer service will check on its next invocation */ | /* The index of tx queue that the timer service will check on its next invocation */ | ||||
| uint16_t check_tx_queue_idx; | uint16_t check_tx_queue_idx; | ||||
| uint16_t rx_buf_size_dqo; | |||||
| }; | }; | ||||
| static inline bool | static inline bool | ||||
| gve_get_state_flag(struct gve_priv *priv, int pos) | gve_get_state_flag(struct gve_priv *priv, int pos) | ||||
| { | { | ||||
| return (BIT_ISSET(GVE_NUM_STATE_FLAGS, pos, &priv->state_flags)); | return (BIT_ISSET(GVE_NUM_STATE_FLAGS, pos, &priv->state_flags)); | ||||
| } | } | ||||
| Show All 17 Lines | |||||
| static inline bool | static inline bool | ||||
| gve_is_qpl(struct gve_priv *priv) | gve_is_qpl(struct gve_priv *priv) | ||||
| { | { | ||||
| return (priv->queue_format == GVE_GQI_QPL_FORMAT || | return (priv->queue_format == GVE_GQI_QPL_FORMAT || | ||||
| priv->queue_format == GVE_DQO_QPL_FORMAT); | priv->queue_format == GVE_DQO_QPL_FORMAT); | ||||
| } | } | ||||
| static inline bool | |||||
| gve_is_4k_rx_buf(struct gve_priv *priv) | |||||
| { | |||||
| return (priv->rx_buf_size_dqo == GVE_4K_RX_BUFFER_SIZE_DQO); | |||||
| } | |||||
| static inline bus_size_t | |||||
| gve_rx_dqo_mbuf_segment_size(struct gve_priv *priv) | |||||
| { | |||||
| return (gve_is_4k_rx_buf(priv) ? MJUMPAGESIZE : MCLBYTES); | |||||
Done Inline ActionsDo you need _Static_asserts which verify that MJUMPAGESIZE == 4096 and MCLBYTES == 2048? The latter in particular might not hold; I'm aware of some downstreams which tweak that value, so it'd be nice to at least fail to build in that case if necessary. markj: Do you need `_Static_asserts` which verify that MJUMPAGESIZE == 4096 and MCLBYTES == 2048? The… | |||||
| } | |||||
| /* Defined in gve_main.c */ | /* Defined in gve_main.c */ | ||||
| void gve_schedule_reset(struct gve_priv *priv); | void gve_schedule_reset(struct gve_priv *priv); | ||||
| int gve_adjust_tx_queues(struct gve_priv *priv, uint16_t new_queue_cnt); | int gve_adjust_tx_queues(struct gve_priv *priv, uint16_t new_queue_cnt); | ||||
| int gve_adjust_rx_queues(struct gve_priv *priv, uint16_t new_queue_cnt); | int gve_adjust_rx_queues(struct gve_priv *priv, uint16_t new_queue_cnt); | ||||
| int gve_adjust_ring_sizes(struct gve_priv *priv, uint16_t new_desc_cnt, bool is_rx); | int gve_adjust_ring_sizes(struct gve_priv *priv, uint16_t new_desc_cnt, bool is_rx); | ||||
| /* Register access functions defined in gve_utils.c */ | /* Register access functions defined in gve_utils.c */ | ||||
| uint32_t gve_reg_bar_read_4(struct gve_priv *priv, bus_size_t offset); | uint32_t gve_reg_bar_read_4(struct gve_priv *priv, bus_size_t offset); | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
| /* Miscellaneous functions defined in gve_utils.c */ | /* Miscellaneous functions defined in gve_utils.c */ | ||||
| void gve_invalidate_timestamp(int64_t *timestamp_sec); | void gve_invalidate_timestamp(int64_t *timestamp_sec); | ||||
| int64_t gve_seconds_since(int64_t *timestamp_sec); | int64_t gve_seconds_since(int64_t *timestamp_sec); | ||||
| void gve_set_timestamp(int64_t *timestamp_sec); | void gve_set_timestamp(int64_t *timestamp_sec); | ||||
| bool gve_timestamp_valid(int64_t *timestamp_sec); | bool gve_timestamp_valid(int64_t *timestamp_sec); | ||||
| /* Systcl functions defined in gve_sysctl.c */ | /* Systcl functions defined in gve_sysctl.c */ | ||||
| extern bool gve_disable_hw_lro; | extern bool gve_disable_hw_lro; | ||||
| extern bool gve_allow_4k_rx_buffers; | |||||
| extern char gve_queue_format[8]; | extern char gve_queue_format[8]; | ||||
| extern char gve_version[8]; | extern char gve_version[8]; | ||||
| void gve_setup_sysctl(struct gve_priv *priv); | void gve_setup_sysctl(struct gve_priv *priv); | ||||
| void gve_accum_stats(struct gve_priv *priv, uint64_t *rpackets, | void gve_accum_stats(struct gve_priv *priv, uint64_t *rpackets, | ||||
| uint64_t *rbytes, uint64_t *rx_dropped_pkt, uint64_t *tpackets, | uint64_t *rbytes, uint64_t *rx_dropped_pkt, uint64_t *tpackets, | ||||
| uint64_t *tbytes, uint64_t *tx_dropped_pkt); | uint64_t *tbytes, uint64_t *tx_dropped_pkt); | ||||
| /* Stats functions defined in gve_utils.c */ | /* Stats functions defined in gve_utils.c */ | ||||
| void gve_alloc_counters(counter_u64_t *stat, int num_stats); | void gve_alloc_counters(counter_u64_t *stat, int num_stats); | ||||
| void gve_free_counters(counter_u64_t *stat, int num_stats); | void gve_free_counters(counter_u64_t *stat, int num_stats); | ||||
| #endif /* _GVE_FBSD_H_ */ | #endif /* _GVE_FBSD_H_ */ | ||||
Sorry, I realized that this will trivially fail on arm64 when the page size is 16KB. There, we define MJUMPAGESIZE == 8096 (which is admittedly a bit odd). Using 8KB buffers is obviously suboptimal, but I'd expect it to work--can we relax this assertion to MJUMPAGESIZE >= GVE_4K_RX_BUFFER_SIZE_DQO?