File Index
Files and directories
Sign in
FILE

hbg_txrx.h

File preview with syntax highlighting.

linux-6.19.14/drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.h C
 1/* SPDX-License-Identifier: GPL-2.0+ */
 2/* Copyright (c) 2024 Hisilicon Limited. */
 3
 4#ifndef __HBG_TXRX_H
 5#define __HBG_TXRX_H
 6
 7#include <linux/etherdevice.h>
 8#include "hbg_hw.h"
 9
10static inline u32 hbg_spec_max_frame_len(struct hbg_priv *priv,
11					 enum hbg_dir dir)
12{
13	return (dir == HBG_DIR_TX) ? priv->dev_specs.max_frame_len :
14		priv->dev_specs.rx_buf_size;
15}
16
17static inline u32 hbg_get_spec_fifo_max_num(struct hbg_priv *priv,
18					    enum hbg_dir dir)
19{
20	return (dir == HBG_DIR_TX) ? priv->dev_specs.tx_fifo_num :
21		priv->dev_specs.rx_fifo_num;
22}
23
24static inline bool hbg_fifo_is_full(struct hbg_priv *priv, enum hbg_dir dir)
25{
26	return hbg_hw_get_fifo_used_num(priv, dir) >=
27	       hbg_get_spec_fifo_max_num(priv, dir);
28}
29
30static inline u32 hbg_get_queue_used_num(struct hbg_ring *ring)
31{
32	u32 len = READ_ONCE(ring->len);
33
34	if (!len)
35		return 0;
36
37	return (READ_ONCE(ring->ntu) + len - READ_ONCE(ring->ntc)) % len;
38}
39
40netdev_tx_t hbg_net_start_xmit(struct sk_buff *skb, struct net_device *netdev);
41int hbg_txrx_init(struct hbg_priv *priv);
42void hbg_txrx_uninit(struct hbg_priv *priv);
43
44#endif
~/ Read-only file preview.