f-stack/dpdk/drivers/net/enic/base/rq_enet_desc.h

49 lines
1.3 KiB
C
Raw Normal View History

2019-06-25 11:12:58 +00:00
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright 2008-2017 Cisco Systems, Inc. All rights reserved.
2017-04-21 10:43:26 +00:00
* Copyright 2007 Nuova Systems, Inc. All rights reserved.
*/
#ifndef _RQ_ENET_DESC_H_
#define _RQ_ENET_DESC_H_
2021-02-05 08:48:47 +00:00
#include <rte_byteorder.h>
2017-04-21 10:43:26 +00:00
/* Ethernet receive queue descriptor: 16B */
struct rq_enet_desc {
2021-02-05 08:48:47 +00:00
uint64_t address;
uint16_t length_type;
uint8_t reserved[6];
2017-04-21 10:43:26 +00:00
};
enum rq_enet_type_types {
RQ_ENET_TYPE_ONLY_SOP = 0,
RQ_ENET_TYPE_NOT_SOP = 1,
RQ_ENET_TYPE_RESV2 = 2,
RQ_ENET_TYPE_RESV3 = 3,
};
#define RQ_ENET_ADDR_BITS 64
#define RQ_ENET_LEN_BITS 14
#define RQ_ENET_LEN_MASK ((1 << RQ_ENET_LEN_BITS) - 1)
#define RQ_ENET_TYPE_BITS 2
#define RQ_ENET_TYPE_MASK ((1 << RQ_ENET_TYPE_BITS) - 1)
static inline void rq_enet_desc_enc(volatile struct rq_enet_desc *desc,
2021-02-05 08:48:47 +00:00
uint64_t address, uint8_t type, uint16_t length)
2017-04-21 10:43:26 +00:00
{
2021-02-05 08:48:47 +00:00
desc->address = rte_cpu_to_le_64(address);
desc->length_type = rte_cpu_to_le_16((length & RQ_ENET_LEN_MASK) |
2017-04-21 10:43:26 +00:00
((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS));
}
static inline void rq_enet_desc_dec(struct rq_enet_desc *desc,
2021-02-05 08:48:47 +00:00
uint64_t *address, uint8_t *type, uint16_t *length)
2017-04-21 10:43:26 +00:00
{
2021-02-05 08:48:47 +00:00
*address = rte_le_to_cpu_64(desc->address);
*length = rte_le_to_cpu_16(desc->length_type) & RQ_ENET_LEN_MASK;
*type = (uint8_t)((rte_le_to_cpu_16(desc->length_type) >>
RQ_ENET_LEN_BITS) & RQ_ENET_TYPE_MASK);
2017-04-21 10:43:26 +00:00
}
#endif /* _RQ_ENET_DESC_H_ */