CNDP  22.08.0
netdev_funcs.h File Reference
#include <stdint.h>
#include <cne_common.h>

Go to the source code of this file.

Data Structures

struct  netdev_link
 
struct  offloads
 

Macros

#define ETH_LINK_HALF_DUPLEX   0
 
#define ETH_LINK_FULL_DUPLEX   1
 
#define ETH_LINK_DOWN   0
 
#define ETH_LINK_UP   1
 
#define ETH_LINK_FIXED   0
 
#define ETH_LINK_AUTONEG   1
 
#define CNE_ETH_SPEED_NUM_NONE   0
 
#define CNE_ETH_SPEED_NUM_10M   10
 
#define CNE_ETH_SPEED_NUM_100M   100
 
#define CNE_ETH_SPEED_NUM_1G   1000
 
#define CNE_ETH_SPEED_NUM_2_5G   2500
 
#define CNE_ETH_SPEED_NUM_5G   5000
 
#define CNE_ETH_SPEED_NUM_10G   10000
 
#define CNE_ETH_SPEED_NUM_20G   20000
 
#define CNE_ETH_SPEED_NUM_25G   25000
 
#define CNE_ETH_SPEED_NUM_40G   40000
 
#define CNE_ETH_SPEED_NUM_50G   50000
 
#define CNE_ETH_SPEED_NUM_56G   56000
 
#define CNE_ETH_SPEED_NUM_100G   100000
 
#define CNE_ETH_SPEED_NUM_200G   200000
 
#define CNE_ETH_SPEED_NUM_400G   400000
 
#define CNE_ETH_SPEED_NUM_UNKNOWN   UINT32_MAX
 

Functions

CNDP_API int netdev_change_flags (const char *if_name, uint32_t flags, uint32_t mask)
 
CNDP_API int netdev_promiscuous_enable (const char *if_name)
 
CNDP_API int netdev_promiscuous_disable (const char *if_name)
 
CNDP_API int netdev_promiscuous_get (const char *if_name)
 
CNDP_API int netdev_set_link_up (const char *if_name)
 
CNDP_API int netdev_set_link_down (const char *if_name)
 
CNDP_API int netdev_get_mac_addr (const char *ifname, struct ether_addr *eth_addr)
 
CNDP_API int netdev_get_link (const char *ifname, struct netdev_link *link)
 
CNDP_API int netdev_get_offloads (const char *ifname, struct offloads *off)
 
CNDP_API int netdev_get_channels (const char *ifname)
 
CNDP_API int netdev_get_ring_params (const char *ifname, uint32_t *rx_nb_desc, uint32_t *tx_nb_desc)
 

Detailed Description

API for netdev modification like setting promiscuous mode, link up/down, etc.

Definition in file netdev_funcs.h.

Macro Definition Documentation

◆ ETH_LINK_HALF_DUPLEX

#define ETH_LINK_HALF_DUPLEX   0

Half-duplex connection (see link_duplex).

Definition at line 33 of file netdev_funcs.h.

◆ ETH_LINK_FULL_DUPLEX

#define ETH_LINK_FULL_DUPLEX   1

Full-duplex connection (see link_duplex).

Definition at line 34 of file netdev_funcs.h.

◆ ETH_LINK_DOWN

#define ETH_LINK_DOWN   0

Link is down (see link_status).

Definition at line 35 of file netdev_funcs.h.

◆ ETH_LINK_UP

#define ETH_LINK_UP   1

Link is up (see link_status).

Definition at line 36 of file netdev_funcs.h.

◆ ETH_LINK_FIXED

#define ETH_LINK_FIXED   0

No autonegotiation (see link_autoneg).

Definition at line 37 of file netdev_funcs.h.

◆ ETH_LINK_AUTONEG

#define ETH_LINK_AUTONEG   1

Autonegotiated (see link_autoneg).

Definition at line 38 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_NONE

#define CNE_ETH_SPEED_NUM_NONE   0

Ethernet numeric link speeds in Mbps Not defined

Definition at line 43 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_10M

#define CNE_ETH_SPEED_NUM_10M   10

10 Mbps

Definition at line 44 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_100M

#define CNE_ETH_SPEED_NUM_100M   100

100 Mbps

Definition at line 45 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_1G

#define CNE_ETH_SPEED_NUM_1G   1000

1 Gbps

Definition at line 46 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_2_5G

#define CNE_ETH_SPEED_NUM_2_5G   2500

2.5 Gbps

Definition at line 47 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_5G

#define CNE_ETH_SPEED_NUM_5G   5000

5 Gbps

Definition at line 48 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_10G

#define CNE_ETH_SPEED_NUM_10G   10000

10 Gbps

Definition at line 49 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_20G

#define CNE_ETH_SPEED_NUM_20G   20000

20 Gbps

Definition at line 50 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_25G

#define CNE_ETH_SPEED_NUM_25G   25000

25 Gbps

Definition at line 51 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_40G

#define CNE_ETH_SPEED_NUM_40G   40000

40 Gbps

Definition at line 52 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_50G

#define CNE_ETH_SPEED_NUM_50G   50000

50 Gbps

Definition at line 53 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_56G

#define CNE_ETH_SPEED_NUM_56G   56000

56 Gbps

Definition at line 54 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_100G

#define CNE_ETH_SPEED_NUM_100G   100000

100 Gbps

Definition at line 55 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_200G

#define CNE_ETH_SPEED_NUM_200G   200000

200 Gbps

Definition at line 56 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_400G

#define CNE_ETH_SPEED_NUM_400G   400000

400 Gbps

Definition at line 57 of file netdev_funcs.h.

◆ CNE_ETH_SPEED_NUM_UNKNOWN

#define CNE_ETH_SPEED_NUM_UNKNOWN   UINT32_MAX

Unknown

Definition at line 58 of file netdev_funcs.h.

Function Documentation

◆ netdev_change_flags()

CNDP_API int netdev_change_flags ( const char *  if_name,
uint32_t  flags,
uint32_t  mask 
)

Set a netdev flags.

Parameters
if_nameThe lport identifier of the Ethernet device.
flagsThe flags to set in the netdev
maskThe mask used to filter flags
Returns
(-1) on error or 0 on success

◆ netdev_promiscuous_enable()

CNDP_API int netdev_promiscuous_enable ( const char *  if_name)

Enable promiscuous mode on the given netdev

Parameters
if_nameThe lport identifier of the Ethernet device.
Returns
0 success or -1 on error

◆ netdev_promiscuous_disable()

CNDP_API int netdev_promiscuous_disable ( const char *  if_name)

Disable promiscuous mode on the given netdev

Parameters
if_nameThe lport identifier of the Ethernet device.
Returns
0 success or -1 on error

◆ netdev_promiscuous_get()

CNDP_API int netdev_promiscuous_get ( const char *  if_name)

Return the value of promiscuous mode for an netdev device.

Parameters
if_nameThe lport identifier of the Ethernet device.
Returns
  • (1) if promiscuous is enabled
  • (0) if promiscuous is disabled.
  • (-1) on error

◆ netdev_set_link_up()

CNDP_API int netdev_set_link_up ( const char *  if_name)

Link up an Ethernet device.

Parameters
if_nameThe port identifier of the Ethernet device.
Returns
0 success or -1 on error

◆ netdev_set_link_down()

CNDP_API int netdev_set_link_down ( const char *  if_name)

Link down an Ethernet device.

Parameters
if_nameThe port identifier of the Ethernet device.
Returns
0 success or -1 on error

◆ netdev_get_mac_addr()

CNDP_API int netdev_get_mac_addr ( const char *  ifname,
struct ether_addr eth_addr 
)

Get MAC address from interface name

Parameters
ifnameThe interface name string or if_name
eth_addrThe location to return the MAC address if a valid address.
Returns
-1 on error or o on success
Examples
examples/vpp-plugin/cndp/device.c.

◆ netdev_get_link()

CNDP_API int netdev_get_link ( const char *  ifname,
struct netdev_link link 
)

Get link status

Parameters
ifnameThe interface name string or if_name
linkThe link info: speed, duplex, autoneg.
Returns
-1 on error or o on success

◆ netdev_get_offloads()

CNDP_API int netdev_get_offloads ( const char *  ifname,
struct offloads off 
)

Get offloads status

Parameters
ifnameThe interface name string or if_name
offThe offloads info: checksum...
Returns
-1 on error or o on success

◆ netdev_get_channels()

CNDP_API int netdev_get_channels ( const char *  ifname)

Get the number of channels/queues on a device

Parameters
ifnameThe interface name string or if_name
Returns
negative error number on error or number of channels on success

◆ netdev_get_ring_params()

CNDP_API int netdev_get_ring_params ( const char *  ifname,
uint32_t *  rx_nb_desc,
uint32_t *  tx_nb_desc 
)

Get the number of descriptors in a ring

Parameters
ifnameThe interface name string or if_name
rx_nb_descThe location to return the number of RX descriptors (maybe NULL)
tx_nb_descThe location to return the number of TX descriptors (maybe NULL) Either rx_nb_desc or tx_nb_desc maybe NULL but not both
Returns
negative error number on error or 0 success