LCOV - code coverage report
Current view: top level - drivers/net/r8169 - r8169_ethdev.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1 0.0 %
Date: 2025-12-01 19:08:10 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2024 Realtek Corporation. All rights reserved
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef R8169_ETHDEV_H
       6                 :            : #define R8169_ETHDEV_H
       7                 :            : 
       8                 :            : #include <stdint.h>
       9                 :            : 
      10                 :            : #include <rte_ethdev.h>
      11                 :            : #include <rte_ethdev_core.h>
      12                 :            : 
      13                 :            : #include "r8169_compat.h"
      14                 :            : 
      15                 :            : struct rtl_hw;
      16                 :            : 
      17                 :            : struct rtl_hw_ops {
      18                 :            :         void (*hw_config)(struct rtl_hw *hw);
      19                 :            :         void (*hw_init_rxcfg)(struct rtl_hw *hw);
      20                 :            :         void (*hw_ephy_config)(struct rtl_hw *hw);
      21                 :            :         void (*hw_phy_config)(struct rtl_hw *hw);
      22                 :            :         void (*hw_mac_mcu_config)(struct rtl_hw *hw);
      23                 :            :         void (*hw_phy_mcu_config)(struct rtl_hw *hw);
      24                 :            : };
      25                 :            : 
      26                 :            : /* Flow control settings */
      27                 :            : enum rtl_fc_mode {
      28                 :            :         rtl_fc_none = 0,
      29                 :            :         rtl_fc_rx_pause,
      30                 :            :         rtl_fc_tx_pause,
      31                 :            :         rtl_fc_full,
      32                 :            :         rtl_fc_default
      33                 :            : };
      34                 :            : 
      35                 :            : enum rtl_rss_register_content {
      36                 :            :         /* RSS */
      37                 :            :         RSS_CTRL_TCP_IPV4_SUPP     = (1 << 0),
      38                 :            :         RSS_CTRL_IPV4_SUPP         = (1 << 1),
      39                 :            :         RSS_CTRL_TCP_IPV6_SUPP     = (1 << 2),
      40                 :            :         RSS_CTRL_IPV6_SUPP         = (1 << 3),
      41                 :            :         RSS_CTRL_IPV6_EXT_SUPP     = (1 << 4),
      42                 :            :         RSS_CTRL_TCP_IPV6_EXT_SUPP = (1 << 5),
      43                 :            :         RSS_HALF_SUPP              = (1 << 7),
      44                 :            :         RSS_CTRL_UDP_IPV4_SUPP     = (1 << 11),
      45                 :            :         RSS_CTRL_UDP_IPV6_SUPP     = (1 << 12),
      46                 :            :         RSS_CTRL_UDP_IPV6_EXT_SUPP = (1 << 13),
      47                 :            :         RSS_QUAD_CPU_EN            = (1 << 16),
      48                 :            :         RSS_HQ_Q_SUP_R             = (1 << 31),
      49                 :            : };
      50                 :            : 
      51                 :            : #define RTL_RSS_OFFLOAD_ALL ( \
      52                 :            :         RTE_ETH_RSS_IPV4 | \
      53                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
      54                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
      55                 :            :         RTE_ETH_RSS_IPV6 | \
      56                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
      57                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
      58                 :            :         RTE_ETH_RSS_IPV6_EX | \
      59                 :            :         RTE_ETH_RSS_IPV6_TCP_EX | \
      60                 :            :         RTE_ETH_RSS_IPV6_UDP_EX)
      61                 :            : 
      62                 :            : #define RTL_RSS_CTRL_OFFLOAD_ALL ( \
      63                 :            :         RSS_CTRL_TCP_IPV4_SUPP | \
      64                 :            :         RSS_CTRL_IPV4_SUPP | \
      65                 :            :         RSS_CTRL_TCP_IPV6_SUPP | \
      66                 :            :         RSS_CTRL_IPV6_SUPP | \
      67                 :            :         RSS_CTRL_IPV6_EXT_SUPP | \
      68                 :            :         RSS_CTRL_TCP_IPV6_EXT_SUPP | \
      69                 :            :         RSS_CTRL_UDP_IPV4_SUPP | \
      70                 :            :         RSS_CTRL_UDP_IPV6_SUPP | \
      71                 :            :         RSS_CTRL_UDP_IPV6_EXT_SUPP)
      72                 :            : 
      73                 :            : #define RTL_RSS_KEY_SIZE     40  /* size of RSS Hash Key in bytes */
      74                 :            : #define RTL_MAX_INDIRECTION_TABLE_ENTRIES RTE_ETH_RSS_RETA_SIZE_128
      75                 :            : #define RSS_MASK_BITS_OFFSET 8
      76                 :            : #define RSS_CPU_NUM_OFFSET   16
      77                 :            : 
      78                 :            : struct rtl_hw {
      79                 :            :         struct rtl_hw_ops hw_ops;
      80                 :            :         u8  *mmio_addr;
      81                 :            :         u8  *cmac_ioaddr; /* cmac memory map physical address */
      82                 :            :         u8  chipset_name;
      83                 :            :         u8  HwIcVerUnknown;
      84                 :            :         u32 mcfg;
      85                 :            :         u32 mtu;
      86                 :            :         u8  HwSuppIntMitiVer;
      87                 :            :         u16 cur_page;
      88                 :            :         u8  mac_addr[RTE_ETHER_ADDR_LEN];
      89                 :            :         u32 rx_buf_sz;
      90                 :            : 
      91                 :            :         struct rtl_counters *tally_vaddr;
      92                 :            :         u64 tally_paddr;
      93                 :            : 
      94                 :            :         u8  RequirePhyMdiSwapPatch;
      95                 :            :         u8  NotWrMcuPatchCode;
      96                 :            :         u8  HwSuppMacMcuVer;
      97                 :            :         u16 MacMcuPageSize;
      98                 :            :         u64 hw_mcu_patch_code_ver;
      99                 :            :         u64 bin_mcu_patch_code_ver;
     100                 :            : 
     101                 :            :         u8 NotWrRamCodeToMicroP;
     102                 :            :         u8 HwHasWrRamCodeToMicroP;
     103                 :            :         u8 HwSuppCheckPhyDisableModeVer;
     104                 :            : 
     105                 :            :         u16 sw_ram_code_ver;
     106                 :            :         u16 hw_ram_code_ver;
     107                 :            : 
     108                 :            :         u8  autoneg;
     109                 :            :         u8  duplex;
     110                 :            :         u32 speed;
     111                 :            :         u64 advertising;
     112                 :            :         enum rtl_fc_mode fcpause;
     113                 :            : 
     114                 :            :         u32 HwSuppMaxPhyLinkSpeed;
     115                 :            : 
     116                 :            :         u8 HwSuppNowIsOobVer;
     117                 :            : 
     118                 :            :         u16 mcu_pme_setting;
     119                 :            : 
     120                 :            :         /* Enable Tx No Close */
     121                 :            :         u8  HwSuppTxNoCloseVer;
     122                 :            :         u8  EnableTxNoClose;
     123                 :            :         u32 MaxTxDescPtrMask;
     124                 :            : 
     125                 :            :         /* Dash */
     126                 :            :         u8 HwSuppDashVer;
     127                 :            :         u8 DASH;
     128                 :            :         u8 HwSuppOcpChannelVer;
     129                 :            :         u8 AllowAccessDashOcp;
     130                 :            :         u8 HwPkgDet;
     131                 :            :         u8 HwSuppSerDesPhyVer;
     132                 :            : 
     133                 :            :         /* Fiber */
     134                 :            :         u32 HwFiberModeVer;
     135                 :            : 
     136                 :            :         /* Multi queue*/
     137                 :            :         u8 EnableRss;
     138                 :            :         u8 HwSuppRxDescType;
     139                 :            :         u16 RxDescLength;
     140                 :            :         u8 rss_key[RTL_RSS_KEY_SIZE];
     141                 :            :         u8 rss_indir_tbl[RTL_MAX_INDIRECTION_TABLE_ENTRIES];
     142                 :            : };
     143                 :            : 
     144                 :            : struct rtl_sw_stats {
     145                 :            :         u64 tx_packets;
     146                 :            :         u64 tx_bytes;
     147                 :            :         u64 tx_errors;
     148                 :            :         u64 rx_packets;
     149                 :            :         u64 rx_bytes;
     150                 :            :         u64 rx_errors;
     151                 :            : };
     152                 :            : 
     153                 :            : struct rtl_adapter {
     154                 :            :         struct rtl_hw       hw;
     155                 :            :         struct rtl_sw_stats sw_stats;
     156                 :            : };
     157                 :            : 
     158                 :            : /* Struct RxDesc in kernel r8169 */
     159                 :            : struct rtl_rx_desc {
     160                 :            :         u32 opts1;
     161                 :            :         u32 opts2;
     162                 :            :         u64 addr;
     163                 :            : };
     164                 :            : 
     165                 :            : struct rtl_rx_descv3 {
     166                 :            :         union {
     167                 :            :                 struct {
     168                 :            :                         u32 rsv1;
     169                 :            :                         u32 rsv2;
     170                 :            :                 } RxDescDDWord1;
     171                 :            :         };
     172                 :            : 
     173                 :            :         union {
     174                 :            :                 struct {
     175                 :            :                         u32 RSSResult;
     176                 :            :                         u16 HeaderBufferLen;
     177                 :            :                         u16 HeaderInfo;
     178                 :            :                 } RxDescNormalDDWord2;
     179                 :            : 
     180                 :            :                 struct {
     181                 :            :                         u32 rsv5;
     182                 :            :                         u32 rsv6;
     183                 :            :                 } RxDescDDWord2;
     184                 :            :         };
     185                 :            : 
     186                 :            :         union {
     187                 :            :                 u64   addr;
     188                 :            : 
     189                 :            :                 struct {
     190                 :            :                         u32 TimeStampLow;
     191                 :            :                         u32 TimeStampHigh;
     192                 :            :                 } RxDescTimeStamp;
     193                 :            : 
     194                 :            :                 struct {
     195                 :            :                         u32 rsv8;
     196                 :            :                         u32 rsv9;
     197                 :            :                 } RxDescDDWord3;
     198                 :            :         };
     199                 :            : 
     200                 :            :         union {
     201                 :            :                 struct {
     202                 :            :                         u32 opts2;
     203                 :            :                         u32 opts1;
     204                 :            :                 } RxDescNormalDDWord4;
     205                 :            : 
     206                 :            :                 struct {
     207                 :            :                         u16 TimeStampHHigh;
     208                 :            :                         u16 rsv11;
     209                 :            :                         u32 opts1;
     210                 :            :                 } RxDescPTPDDWord4;
     211                 :            :         };
     212                 :            : };
     213                 :            : 
     214                 :            : struct rtl_rx_descv4 {
     215                 :            :         union {
     216                 :            :                 u64   addr;
     217                 :            : 
     218                 :            :                 struct {
     219                 :            :                         u32 RSSInfo;
     220                 :            :                         u32 RSSResult;
     221                 :            :                 } RxDescNormalDDWord1;
     222                 :            :         };
     223                 :            : 
     224                 :            :         struct {
     225                 :            :                 u32 opts2;
     226                 :            :                 u32 opts1;
     227                 :            :         } RxDescNormalDDWord2;
     228                 :            : };
     229                 :            : 
     230                 :            : enum rx_desc_ring_type {
     231                 :            :         RX_DESC_RING_TYPE_UNKNOWN = 0,
     232                 :            :         RX_DESC_RING_TYPE_1,
     233                 :            :         RX_DESC_RING_TYPE_2,
     234                 :            :         RX_DESC_RING_TYPE_3,
     235                 :            :         RX_DESC_RING_TYPE_4,
     236                 :            :         RX_DESC_RING_TYPE_MAX
     237                 :            : };
     238                 :            : 
     239                 :            : enum rx_desc_len {
     240                 :            :         RX_DESC_LEN_TYPE_1 = (sizeof(struct rtl_rx_desc)),
     241                 :            :         RX_DESC_LEN_TYPE_3 = (sizeof(struct rtl_rx_descv3)),
     242                 :            :         RX_DESC_LEN_TYPE_4 = (sizeof(struct rtl_rx_descv4))
     243                 :            : };
     244                 :            : 
     245                 :            : #define RTL_DEV_PRIVATE(eth_dev) \
     246                 :            :         ((struct rtl_adapter *)((eth_dev)->data->dev_private))
     247                 :            : 
     248                 :            : #define R8169_LINK_CHECK_TIMEOUT  50   /* 10s */
     249                 :            : #define R8169_LINK_CHECK_INTERVAL 200  /* ms */
     250                 :            : 
     251                 :            : #define PCI_READ_CONFIG_BYTE(dev, val, where) \
     252                 :            :         rte_pci_read_config(dev, val, 1, where)
     253                 :            : 
     254                 :            : #define PCI_READ_CONFIG_WORD(dev, val, where) \
     255                 :            :         rte_pci_read_config(dev, val, 2, where)
     256                 :            : 
     257                 :            : #define PCI_READ_CONFIG_DWORD(dev, val, where) \
     258                 :            :         rte_pci_read_config(dev, val, 4, where)
     259                 :            : 
     260                 :            : #define PCI_WRITE_CONFIG_BYTE(dev, val, where) \
     261                 :            :         rte_pci_write_config(dev, val, 1, where)
     262                 :            : 
     263                 :            : #define PCI_WRITE_CONFIG_WORD(dev, val, where) \
     264                 :            :         rte_pci_write_config(dev, val, 2, where)
     265                 :            : 
     266                 :            : #define PCI_WRITE_CONFIG_DWORD(dev, val, where) \
     267                 :            :         rte_pci_write_config(dev, val, 4, where)
     268                 :            : 
     269                 :            : int rtl_rx_init(struct rte_eth_dev *dev);
     270                 :            : int rtl_tx_init(struct rte_eth_dev *dev);
     271                 :            : 
     272                 :            : uint16_t rtl_xmit_pkts(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
     273                 :            : uint16_t rtl_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
     274                 :            : uint16_t rtl_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
     275                 :            :                                  uint16_t nb_pkts);
     276                 :            : 
     277                 :            : void rtl_rx_queue_release(struct rte_eth_dev *dev, uint16_t rx_queue_id);
     278                 :            : void rtl_tx_queue_release(struct rte_eth_dev *dev, uint16_t tx_queue_id);
     279                 :            : 
     280                 :            : void rtl_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
     281                 :            :                       struct rte_eth_rxq_info *qinfo);
     282                 :            : void rtl_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
     283                 :            :                       struct rte_eth_txq_info *qinfo);
     284                 :            : 
     285                 :            : uint64_t rtl_get_rx_port_offloads(struct rtl_hw *hw);
     286                 :            : uint64_t rtl_get_tx_port_offloads(void);
     287                 :            : 
     288                 :            : int rtl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
     289                 :            :                        uint16_t nb_rx_desc, unsigned int socket_id,
     290                 :            :                        const struct rte_eth_rxconf *rx_conf,
     291                 :            :                        struct rte_mempool *mb_pool);
     292                 :            : int rtl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
     293                 :            :                        uint16_t nb_tx_desc, unsigned int socket_id,
     294                 :            :                        const struct rte_eth_txconf *tx_conf);
     295                 :            : 
     296                 :            : int rtl_tx_done_cleanup(void *tx_queue, uint32_t free_cnt);
     297                 :            : 
     298                 :            : int rtl_stop_queues(struct rte_eth_dev *dev);
     299                 :            : void rtl_free_queues(struct rte_eth_dev *dev);
     300                 :            : 
     301                 :            : static inline struct rtl_rx_desc*
     302                 :            : rtl_get_rxdesc(struct rtl_hw *hw, struct rtl_rx_desc *base, u32 const number)
     303                 :            : {
     304   [ #  #  #  #  :          0 :         return (struct rtl_rx_desc *)((u8 *)base + hw->RxDescLength * number);
          #  #  #  #  #  
                #  #  # ]
     305                 :            : }
     306                 :            : 
     307                 :            : #endif /* R8169_ETHDEV_H */

Generated by: LCOV version 1.14