Blog
Community
Development
Documentation
CNDP
22.08.0
Toggle main menu visibility
Loading...
Searching...
No Matches
pktdev.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright (c) 2019-2022 Intel Corporation.
3
*/
4
5
#ifndef __PKTDEV_H
6
#define __PKTDEV_H
7
8
#include <
cne_common.h
>
9
#include <errno.h>
// for EINVAL, ENOTSUP
10
#include <stddef.h>
// for NULL
11
#include <stdint.h>
// for uint16_t, uint32_t, uint64_t, uint8_t
12
#include <x86intrin.h>
// _mm_shuffle_xxx
13
#include <
mempool.h
>
// for mempool_t
14
#include <
pktmbuf.h
>
// for pktmbuf_t
15
#include <emmintrin.h>
// for _mm_loadu_si128, _mm_set_epi8, _mm_storeu_s...
16
#include <stdbool.h>
// for bool
17
#include <tmmintrin.h>
// for _mm_shuffle_epi8
18
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif
27
28
#define PKTDEV_FOREACH(x) for (int x = 0; x < CNE_MAX_ETHPORTS; x++)
29
35
#define PKTDEV_FALLBACK_RX_RINGSIZE 512
36
#define PKTDEV_FALLBACK_TX_RINGSIZE 512
37
#define PKTDEV_FALLBACK_RX_NBQUEUES 1
38
#define PKTDEV_FALLBACK_TX_NBQUEUES 1
39
#define PKTDEV_ADMIN_STATE_DOWN 0xFFFF
40
41
#include <
cne_lport.h
>
42
47
struct
pktdev_rxq_info
{
48
mempool_t
*
mp
;
49
uint16_t
nb_desc
;
50
}
__cne_cache_min_aligned
;
51
56
struct
pktdev_txq_info
{
57
uint16_t
nb_desc
;
58
}
__cne_cache_min_aligned
;
59
65
struct
pktdev_portconf
{
66
uint16_t
burst_size
;
67
uint16_t
ring_size
;
68
};
69
73
79
struct
pktdev_info
{
80
const
char
*
driver_name
;
81
unsigned
int
if_index
;
83
bool
admin_state
;
84
uint16_t
min_mtu
;
85
uint16_t
max_mtu
;
86
uint32_t
min_rx_bufsize
;
87
uint32_t
max_rx_pktlen
;
88
uint32_t
min_tx_bufsize
;
89
uint8_t
hash_key_size
;
91
uint32_t
speed_capa
;
93
struct
pktdev_portconf
default_rxportconf
;
95
struct
pktdev_portconf
default_txportconf
;
97
uint64_t
dev_capa
;
98
}
__cne_cache_aligned
;
99
100
#include <
pktdev_api.h
>
// for pktdev_admin_state
101
#include <
pktdev_core.h
>
// for cne_pktdev, pktdev_data, pktdev_devices
102
103
#include "
cne_common.h
"
// for CNE_MAX_ETHPORTS, __cne_cache_min_aligned
104
#include "
cne_log.h
"
// for CNE_LOG_ERR
105
106
// IWYU pragma: no_forward_declare cne_mempool
107
182
static
inline
uint16_t
183
pktdev_rx_burst
(uint16_t lport_id, pktmbuf_t **rx_pkts,
const
uint16_t nb_pkts)
184
{
185
struct
cne_pktdev *dev = &pktdev_devices[lport_id];
186
uint16_t nb_rx;
187
188
#ifdef PKTDEV_DEBUG
189
if
(dev->rx_pkt_burst == NULL)
190
return
0;
191
#endif
192
193
/* Check packet stream status */
194
if
(!
pktdev_admin_state
(lport_id)) {
195
CNE_DEBUG(
"Packet stream is disabled for '%d'\n"
, lport_id);
196
return
PKTDEV_ADMIN_STATE_DOWN;
197
}
198
199
nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queue, rx_pkts, nb_pkts);
200
201
return
nb_rx;
202
}
203
257
static
inline
uint16_t
258
pktdev_tx_burst
(uint16_t lport_id, pktmbuf_t **tx_pkts, uint16_t nb_pkts)
259
{
260
struct
cne_pktdev *dev;
261
262
#ifdef PKTDEV_DEBUG
263
if
(lport_id >= CNE_MAX_ETHPORTS)
264
return
0;
265
#endif
266
267
dev = &pktdev_devices[lport_id];
268
269
#ifdef PKTDEV_DEBUG
270
if
(dev->tx_pkt_burst == NULL)
271
return
0;
272
#endif
273
274
/* Check packet stream status */
275
if
(!
pktdev_admin_state
(lport_id)) {
276
CNE_DEBUG(
"Packet stream is disabled for '%d'\n"
, lport_id);
277
return
PKTDEV_ADMIN_STATE_DOWN;
278
}
279
280
return
(*dev->tx_pkt_burst)(dev->data->tx_queue, tx_pkts, nb_pkts);
281
}
282
329
static
inline
uint16_t
330
pktdev_tx_prepare
(uint16_t lport_id, pktmbuf_t **tx_pkts, uint16_t nb_pkts)
331
{
332
struct
cne_pktdev *dev;
333
334
dev = &pktdev_devices[lport_id];
335
336
if
(!dev->tx_pkt_prepare)
337
return
nb_pkts;
338
339
return
(*dev->tx_pkt_prepare)(dev->data->tx_queue, tx_pkts, nb_pkts);
340
}
341
350
static
inline
void
351
pktdev_mac_swap
(
void
*data)
352
{
358
__m128i shfl_msk = _mm_set_epi8(15, 14, 13, 12, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6);
359
360
__m128i hdr = _mm_loadu_si128((
const
__m128i_u *)data);
361
hdr = _mm_shuffle_epi8(hdr, shfl_msk);
362
_mm_storeu_si128((__m128i_u *)data, hdr);
363
}
364
365
#ifdef __cplusplus
366
}
367
#endif
368
369
#endif
/* __PKTDEV_H */
cne_common.h
__cne_cache_min_aligned
#define __cne_cache_min_aligned
Definition
cne_common.h:382
__cne_cache_aligned
#define __cne_cache_aligned
Definition
cne_common.h:379
cne_log.h
cne_lport.h
mempool.h
mempool_t
void mempool_t
Definition
mempool.h:45
pktdev_tx_burst
static uint16_t pktdev_tx_burst(uint16_t lport_id, pktmbuf_t **tx_pkts, uint16_t nb_pkts)
Definition
pktdev.h:258
pktdev_tx_prepare
static uint16_t pktdev_tx_prepare(uint16_t lport_id, pktmbuf_t **tx_pkts, uint16_t nb_pkts)
Definition
pktdev.h:330
pktdev_rx_burst
static uint16_t pktdev_rx_burst(uint16_t lport_id, pktmbuf_t **rx_pkts, const uint16_t nb_pkts)
Definition
pktdev.h:183
pktdev_mac_swap
static void pktdev_mac_swap(void *data)
Definition
pktdev.h:351
pktdev_api.h
pktdev_admin_state
CNDP_API bool pktdev_admin_state(uint16_t lport_id)
pktdev_core.h
pktmbuf.h
pktdev_info
Definition
pktdev.h:79
pktdev_info::if_index
unsigned int if_index
Definition
pktdev.h:81
pktdev_info::min_tx_bufsize
uint32_t min_tx_bufsize
Definition
pktdev.h:88
pktdev_info::default_rxportconf
struct pktdev_portconf default_rxportconf
Definition
pktdev.h:93
pktdev_info::dev_capa
uint64_t dev_capa
Definition
pktdev.h:97
pktdev_info::min_rx_bufsize
uint32_t min_rx_bufsize
Definition
pktdev.h:86
pktdev_info::admin_state
bool admin_state
Definition
pktdev.h:83
pktdev_info::default_txportconf
struct pktdev_portconf default_txportconf
Definition
pktdev.h:95
pktdev_info::max_rx_pktlen
uint32_t max_rx_pktlen
Definition
pktdev.h:87
pktdev_info::max_mtu
uint16_t max_mtu
Definition
pktdev.h:85
pktdev_info::min_mtu
uint16_t min_mtu
Definition
pktdev.h:84
pktdev_info::driver_name
const char * driver_name
Definition
pktdev.h:80
pktdev_info::hash_key_size
uint8_t hash_key_size
Definition
pktdev.h:89
pktdev_info::speed_capa
uint32_t speed_capa
Definition
pktdev.h:91
pktdev_portconf
Definition
pktdev.h:65
pktdev_portconf::burst_size
uint16_t burst_size
Definition
pktdev.h:66
pktdev_portconf::ring_size
uint16_t ring_size
Definition
pktdev.h:67
pktdev_rxq_info
Definition
pktdev.h:47
pktdev_rxq_info::mp
mempool_t * mp
Definition
pktdev.h:48
pktdev_rxq_info::nb_desc
uint16_t nb_desc
Definition
pktdev.h:49
pktdev_txq_info
Definition
pktdev.h:56
pktdev_txq_info::nb_desc
uint16_t nb_desc
Definition
pktdev.h:57
lib
core
pktdev
pktdev.h
Generated by
1.18.0