Blog
Community
Development
Documentation
CNDP
22.08.0
Toggle main menu visibility
Loading...
Searching...
No Matches
cnet_eth.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright (c) 2016-2022 Intel Corporation
3
*/
4
5
#ifndef __CNET_ETH_H
6
#define __CNET_ETH_H
7
12
13
#include <
mempool.h
>
// for mempool_t
14
#include <endian.h>
// for htole64
15
#include <net/ethernet.h>
// for ether_addr
16
#include <stdint.h>
// for uint64_t, uint16_t, uint8_t
17
18
#include "
cnet_const.h
"
// for iofunc_t
19
#include "
cne_inet.h
"
// for _in_addr
20
#include "
cnet_netif.h
"
// for netif
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
26
#define IPV4_ADDR_SIZE 4
27
28
#define CNET_MAX_QIDS 16
29
struct
eth_port_data {
30
uint16_t pid;
31
uint16_t nb_qids;
32
uint16_t qids[CNET_MAX_QIDS];
33
};
34
35
struct
eth_stats {
36
uint64_t input_cnt;
37
uint64_t lookup_ok;
38
uint64_t lookup_failed;
39
uint64_t raw_output;
40
uint64_t eth_pkt_len;
41
uint64_t ipv4_output;
42
};
43
44
static
inline
int
45
cnet_eth_compare(
struct
ether_addr
*c1,
struct
ether_addr
*c2)
46
{
47
uint64_t p1 = *(uint64_t *)c1;
48
uint64_t p2 = *(uint64_t *)c2;
49
50
p1 &= htole64(0xFFFFFFFFFFFF0000L);
51
p2 &= htole64(0xFFFFFFFFFFFF0000L);
52
53
return
p1 == p2;
54
}
55
56
static
inline
void
57
cnet_eth_set_broadcast(
struct
ether_addr
*ea)
58
{
59
uint16_t *p = (uint16_t *)&ea->
ether_addr_octet
;
60
61
p[0] = 0xFFFF;
62
p[1] = 0xFFFF;
63
p[2] = 0xFFFF;
64
}
65
66
static
inline
void
67
cnet_eth_set_multicast(
struct
ether_addr
*ea,
struct
in_addr *ip)
68
{
69
ea->
ether_addr_octet
[0] = 0x01;
70
ea->
ether_addr_octet
[1] = 0x00;
71
ea->
ether_addr_octet
[2] = 0x5e;
72
ea->
ether_addr_octet
[3] = (ip->s_addr >> 24) & 0xFF;
73
ea->
ether_addr_octet
[4] = (ip->s_addr >> 16) & 0xFF;
74
ea->
ether_addr_octet
[5] = (ip->s_addr >> 8) & 0xFF;
75
}
76
77
#ifdef __cplusplus
78
}
79
#endif
80
81
#endif
/* __CNET_ETH_H */
cne_inet.h
cnet_const.h
cnet_netif.h
mempool.h
ether_addr
Definition
cne_ether.h:52
ether_addr::ether_addr_octet
uint8_t ether_addr_octet[ETH_ALEN]
Definition
cne_ether.h:53
lib
cnet
eth
cnet_eth.h
Generated by
1.18.0