#include <rte_esp.h>
#include <rte_tcp.h>
#include <rte_udp.h>
+#include <rte_vxlan.h>
#include <rte_cryptodev.h>
#include <rte_cryptodev_pmd.h>
struct lb_data {
uint32_t out[RTE_TABLE_ACTION_LB_TABLE_SIZE];
-} __attribute__((__packed__));
+} __rte_packed;
static int
lb_apply(struct lb_data *data,
return 0;
}
-#define MBUF_SCHED_QUEUE_TC_COLOR(queue, tc, color) \
- ((uint16_t)((((uint64_t)(queue)) & 0x3) | \
- ((((uint64_t)(tc)) & 0x3) << 2) | \
- ((((uint64_t)(color)) & 0x3) << 4)))
-
-#define MBUF_SCHED_COLOR(sched, color) \
- (((sched) & (~0x30LLU)) | ((color) << 4))
-
struct mtr_trtcm_data {
struct rte_meter_trtcm trtcm;
- uint64_t stats[e_RTE_METER_COLORS];
-} __attribute__((__packed__));
+ uint64_t stats[RTE_COLORS];
+} __rte_packed;
#define MTR_TRTCM_DATA_METER_PROFILE_ID_GET(data) \
- (((data)->stats[e_RTE_METER_GREEN] & 0xF8LLU) >> 3)
+ (((data)->stats[RTE_COLOR_GREEN] & 0xF8LLU) >> 3)
static void
mtr_trtcm_data_meter_profile_id_set(struct mtr_trtcm_data *data,
uint32_t profile_id)
{
- data->stats[e_RTE_METER_GREEN] &= ~0xF8LLU;
- data->stats[e_RTE_METER_GREEN] |= (profile_id % 32) << 3;
+ data->stats[RTE_COLOR_GREEN] &= ~0xF8LLU;
+ data->stats[RTE_COLOR_GREEN] |= (profile_id % 32) << 3;
}
#define MTR_TRTCM_DATA_POLICER_ACTION_DROP_GET(data, color)\
(((data)->stats[(color)] & 4LLU) >> 2)
#define MTR_TRTCM_DATA_POLICER_ACTION_COLOR_GET(data, color)\
- ((enum rte_meter_color)((data)->stats[(color)] & 3LLU))
+ ((enum rte_color)((data)->stats[(color)] & 3LLU))
static void
mtr_trtcm_data_policer_action_set(struct mtr_trtcm_data *data,
- enum rte_meter_color color,
+ enum rte_color color,
enum rte_table_action_policer action)
{
if (action == RTE_TABLE_ACTION_POLICER_DROP) {
static uint64_t
mtr_trtcm_data_stats_get(struct mtr_trtcm_data *data,
- enum rte_meter_color color)
+ enum rte_color color)
{
return data->stats[color] >> 8;
}
static void
mtr_trtcm_data_stats_reset(struct mtr_trtcm_data *data,
- enum rte_meter_color color)
+ enum rte_color color)
{
data->stats[color] &= 0xFFLU;
}
}
struct dscp_table_entry_data {
- enum rte_meter_color color;
+ enum rte_color color;
uint16_t tc;
- uint16_t queue_tc_color;
+ uint16_t tc_queue;
};
struct dscp_table_data {
/* Policer actions */
mtr_trtcm_data_policer_action_set(data_tc,
- e_RTE_METER_GREEN,
- p_tc->policer[e_RTE_METER_GREEN]);
+ RTE_COLOR_GREEN,
+ p_tc->policer[RTE_COLOR_GREEN]);
mtr_trtcm_data_policer_action_set(data_tc,
- e_RTE_METER_YELLOW,
- p_tc->policer[e_RTE_METER_YELLOW]);
+ RTE_COLOR_YELLOW,
+ p_tc->policer[RTE_COLOR_YELLOW]);
mtr_trtcm_data_policer_action_set(data_tc,
- e_RTE_METER_RED,
- p_tc->policer[e_RTE_METER_RED]);
+ RTE_COLOR_RED,
+ p_tc->policer[RTE_COLOR_RED]);
}
return 0;
uint32_t dscp,
uint16_t total_length)
{
- uint64_t drop_mask, sched;
- uint64_t *sched_ptr = (uint64_t *) &mbuf->hash.sched;
+ uint64_t drop_mask;
struct dscp_table_entry_data *dscp_entry = &dscp_table->entry[dscp];
- enum rte_meter_color color_in, color_meter, color_policer;
+ enum rte_color color_in, color_meter, color_policer;
uint32_t tc, mp_id;
tc = dscp_entry->tc;
color_in = dscp_entry->color;
data += tc;
mp_id = MTR_TRTCM_DATA_METER_PROFILE_ID_GET(data);
- sched = *sched_ptr;
/* Meter */
color_meter = rte_meter_trtcm_color_aware_check(
drop_mask = MTR_TRTCM_DATA_POLICER_ACTION_DROP_GET(data, color_meter);
color_policer =
MTR_TRTCM_DATA_POLICER_ACTION_COLOR_GET(data, color_meter);
- *sched_ptr = MBUF_SCHED_COLOR(sched, color_policer);
+ rte_mbuf_sched_color_set(mbuf, (uint8_t)color_policer);
return drop_mask;
}
}
struct tm_data {
- uint16_t queue_tc_color;
- uint16_t subport;
- uint32_t pipe;
-} __attribute__((__packed__));
+ uint32_t queue_id;
+ uint32_t reserved;
+} __rte_packed;
static int
tm_apply_check(struct rte_table_action_tm_params *p,
return status;
/* Apply */
- data->queue_tc_color = 0;
- data->subport = (uint16_t) p->subport_id;
- data->pipe = p->pipe_id;
+ data->queue_id = p->subport_id <<
+ (__builtin_ctz(cfg->n_pipes_per_subport) + 4) |
+ p->pipe_id << 4;
return 0;
}
uint32_t dscp)
{
struct dscp_table_entry_data *dscp_entry = &dscp_table->entry[dscp];
- struct tm_data *sched_ptr = (struct tm_data *) &mbuf->hash.sched;
- struct tm_data sched;
-
- sched = *data;
- sched.queue_tc_color = dscp_entry->queue_tc_color;
- *sched_ptr = sched;
+ uint32_t queue_id = data->queue_id |
+ dscp_entry->tc_queue;
+ rte_mbuf_sched_set(mbuf, queue_id, dscp_entry->tc,
+ (uint8_t)dscp_entry->color);
}
/**
case RTE_TABLE_ACTION_ENCAP_MPLS:
case RTE_TABLE_ACTION_ENCAP_PPPOE:
case RTE_TABLE_ACTION_ENCAP_VXLAN:
+ case RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE:
return 1;
default:
return 0;
}
struct encap_ether_data {
- struct ether_hdr ether;
-} __attribute__((__packed__));
+ struct rte_ether_hdr ether;
+};
#define VLAN(pcp, dei, vid) \
((uint16_t)((((uint64_t)(pcp)) & 0x7LLU) << 13) | \
(((uint64_t)(vid)) & 0xFFFLLU)) \
struct encap_vlan_data {
- struct ether_hdr ether;
- struct vlan_hdr vlan;
-} __attribute__((__packed__));
+ struct rte_ether_hdr ether;
+ struct rte_vlan_hdr vlan;
+};
struct encap_qinq_data {
- struct ether_hdr ether;
- struct vlan_hdr svlan;
- struct vlan_hdr cvlan;
-} __attribute__((__packed__));
+ struct rte_ether_hdr ether;
+ struct rte_vlan_hdr svlan;
+ struct rte_vlan_hdr cvlan;
+};
#define ETHER_TYPE_MPLS_UNICAST 0x8847
(((uint64_t)(ttl)) & 0xFFLLU)))
struct encap_mpls_data {
- struct ether_hdr ether;
+ struct rte_ether_hdr ether;
uint32_t mpls[RTE_TABLE_ACTION_MPLS_LABELS_MAX];
uint32_t mpls_count;
-} __attribute__((__packed__));
-
-#define ETHER_TYPE_PPPOE_SESSION 0x8864
+} __rte_packed __rte_aligned(2);
#define PPP_PROTOCOL_IP 0x0021
uint16_t session_id;
uint16_t length;
uint16_t protocol;
-} __attribute__((__packed__));
+};
struct encap_pppoe_data {
- struct ether_hdr ether;
+ struct rte_ether_hdr ether;
struct pppoe_ppp_hdr pppoe_ppp;
-} __attribute__((__packed__));
+};
#define IP_PROTO_UDP 17
struct encap_vxlan_ipv4_data {
- struct ether_hdr ether;
- struct ipv4_hdr ipv4;
- struct udp_hdr udp;
- struct vxlan_hdr vxlan;
-} __attribute__((__packed__));
+ struct rte_ether_hdr ether;
+ struct rte_ipv4_hdr ipv4;
+ struct rte_udp_hdr udp;
+ struct rte_vxlan_hdr vxlan;
+} __rte_packed __rte_aligned(2);
struct encap_vxlan_ipv4_vlan_data {
- struct ether_hdr ether;
- struct vlan_hdr vlan;
- struct ipv4_hdr ipv4;
- struct udp_hdr udp;
- struct vxlan_hdr vxlan;
-} __attribute__((__packed__));
+ struct rte_ether_hdr ether;
+ struct rte_vlan_hdr vlan;
+ struct rte_ipv4_hdr ipv4;
+ struct rte_udp_hdr udp;
+ struct rte_vxlan_hdr vxlan;
+} __rte_packed __rte_aligned(2);
struct encap_vxlan_ipv6_data {
- struct ether_hdr ether;
- struct ipv6_hdr ipv6;
- struct udp_hdr udp;
- struct vxlan_hdr vxlan;
-} __attribute__((__packed__));
+ struct rte_ether_hdr ether;
+ struct rte_ipv6_hdr ipv6;
+ struct rte_udp_hdr udp;
+ struct rte_vxlan_hdr vxlan;
+} __rte_packed __rte_aligned(2);
struct encap_vxlan_ipv6_vlan_data {
- struct ether_hdr ether;
- struct vlan_hdr vlan;
- struct ipv6_hdr ipv6;
- struct udp_hdr udp;
- struct vxlan_hdr vxlan;
-} __attribute__((__packed__));
+ struct rte_ether_hdr ether;
+ struct rte_vlan_hdr vlan;
+ struct rte_ipv6_hdr ipv6;
+ struct rte_udp_hdr udp;
+ struct rte_vxlan_hdr vxlan;
+} __rte_packed __rte_aligned(2);
+
+struct encap_qinq_pppoe_data {
+ struct rte_ether_hdr ether;
+ struct rte_vlan_hdr svlan;
+ struct rte_vlan_hdr cvlan;
+ struct pppoe_ppp_hdr pppoe_ppp;
+} __rte_packed __rte_aligned(2);
static size_t
encap_data_size(struct rte_table_action_encap_config *encap)
else
return sizeof(struct encap_vxlan_ipv6_data);
+ case 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE:
+ return sizeof(struct encap_qinq_pppoe_data);
+
default:
return 0;
}
case RTE_TABLE_ACTION_ENCAP_VXLAN:
return 0;
+ case RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE:
+ return 0;
+
default:
return -EINVAL;
}
{
struct encap_ether_data *d = data;
uint16_t ethertype = (common_cfg->ip_version) ?
- ETHER_TYPE_IPv4 :
- ETHER_TYPE_IPv6;
+ RTE_ETHER_TYPE_IPV4 :
+ RTE_ETHER_TYPE_IPV6;
/* Ethernet */
- ether_addr_copy(&p->ether.ether.da, &d->ether.d_addr);
- ether_addr_copy(&p->ether.ether.sa, &d->ether.s_addr);
+ rte_ether_addr_copy(&p->ether.ether.da, &d->ether.d_addr);
+ rte_ether_addr_copy(&p->ether.ether.sa, &d->ether.s_addr);
d->ether.ether_type = rte_htons(ethertype);
return 0;
{
struct encap_vlan_data *d = data;
uint16_t ethertype = (common_cfg->ip_version) ?
- ETHER_TYPE_IPv4 :
- ETHER_TYPE_IPv6;
+ RTE_ETHER_TYPE_IPV4 :
+ RTE_ETHER_TYPE_IPV6;
/* Ethernet */
- ether_addr_copy(&p->vlan.ether.da, &d->ether.d_addr);
- ether_addr_copy(&p->vlan.ether.sa, &d->ether.s_addr);
- d->ether.ether_type = rte_htons(ETHER_TYPE_VLAN);
+ rte_ether_addr_copy(&p->vlan.ether.da, &d->ether.d_addr);
+ rte_ether_addr_copy(&p->vlan.ether.sa, &d->ether.s_addr);
+ d->ether.ether_type = rte_htons(RTE_ETHER_TYPE_VLAN);
/* VLAN */
d->vlan.vlan_tci = rte_htons(VLAN(p->vlan.vlan.pcp,
{
struct encap_qinq_data *d = data;
uint16_t ethertype = (common_cfg->ip_version) ?
- ETHER_TYPE_IPv4 :
- ETHER_TYPE_IPv6;
+ RTE_ETHER_TYPE_IPV4 :
+ RTE_ETHER_TYPE_IPV6;
/* Ethernet */
- ether_addr_copy(&p->qinq.ether.da, &d->ether.d_addr);
- ether_addr_copy(&p->qinq.ether.sa, &d->ether.s_addr);
- d->ether.ether_type = rte_htons(ETHER_TYPE_QINQ);
+ rte_ether_addr_copy(&p->qinq.ether.da, &d->ether.d_addr);
+ rte_ether_addr_copy(&p->qinq.ether.sa, &d->ether.s_addr);
+ d->ether.ether_type = rte_htons(RTE_ETHER_TYPE_QINQ);
/* SVLAN */
d->svlan.vlan_tci = rte_htons(VLAN(p->qinq.svlan.pcp,
p->qinq.svlan.dei,
p->qinq.svlan.vid));
- d->svlan.eth_proto = rte_htons(ETHER_TYPE_VLAN);
+ d->svlan.eth_proto = rte_htons(RTE_ETHER_TYPE_VLAN);
/* CVLAN */
d->cvlan.vlan_tci = rte_htons(VLAN(p->qinq.cvlan.pcp,
return 0;
}
+static int
+encap_qinq_pppoe_apply(void *data,
+ struct rte_table_action_encap_params *p)
+{
+ struct encap_qinq_pppoe_data *d = data;
+
+ /* Ethernet */
+ rte_ether_addr_copy(&p->qinq.ether.da, &d->ether.d_addr);
+ rte_ether_addr_copy(&p->qinq.ether.sa, &d->ether.s_addr);
+ d->ether.ether_type = rte_htons(RTE_ETHER_TYPE_VLAN);
+
+ /* SVLAN */
+ d->svlan.vlan_tci = rte_htons(VLAN(p->qinq.svlan.pcp,
+ p->qinq.svlan.dei,
+ p->qinq.svlan.vid));
+ d->svlan.eth_proto = rte_htons(RTE_ETHER_TYPE_VLAN);
+
+ /* CVLAN */
+ d->cvlan.vlan_tci = rte_htons(VLAN(p->qinq.cvlan.pcp,
+ p->qinq.cvlan.dei,
+ p->qinq.cvlan.vid));
+ d->cvlan.eth_proto = rte_htons(RTE_ETHER_TYPE_PPPOE_SESSION);
+
+ /* PPPoE and PPP*/
+ d->pppoe_ppp.ver_type_code = rte_htons(0x1100);
+ d->pppoe_ppp.session_id = rte_htons(p->qinq_pppoe.pppoe.session_id);
+ d->pppoe_ppp.length = 0; /* not pre-computed */
+ d->pppoe_ppp.protocol = rte_htons(PPP_PROTOCOL_IP);
+
+ return 0;
+}
+
static int
encap_mpls_apply(void *data,
struct rte_table_action_encap_params *p)
uint32_t i;
/* Ethernet */
- ether_addr_copy(&p->mpls.ether.da, &d->ether.d_addr);
- ether_addr_copy(&p->mpls.ether.sa, &d->ether.s_addr);
+ rte_ether_addr_copy(&p->mpls.ether.da, &d->ether.d_addr);
+ rte_ether_addr_copy(&p->mpls.ether.sa, &d->ether.s_addr);
d->ether.ether_type = rte_htons(ethertype);
/* MPLS */
struct encap_pppoe_data *d = data;
/* Ethernet */
- ether_addr_copy(&p->pppoe.ether.da, &d->ether.d_addr);
- ether_addr_copy(&p->pppoe.ether.sa, &d->ether.s_addr);
- d->ether.ether_type = rte_htons(ETHER_TYPE_PPPOE_SESSION);
+ rte_ether_addr_copy(&p->pppoe.ether.da, &d->ether.d_addr);
+ rte_ether_addr_copy(&p->pppoe.ether.sa, &d->ether.s_addr);
+ d->ether.ether_type = rte_htons(RTE_ETHER_TYPE_PPPOE_SESSION);
/* PPPoE and PPP*/
d->pppoe_ppp.ver_type_code = rte_htons(0x1100);
struct encap_vxlan_ipv4_vlan_data *d = data;
/* Ethernet */
- ether_addr_copy(&p->vxlan.ether.da, &d->ether.d_addr);
- ether_addr_copy(&p->vxlan.ether.sa, &d->ether.s_addr);
- d->ether.ether_type = rte_htons(ETHER_TYPE_VLAN);
+ rte_ether_addr_copy(&p->vxlan.ether.da,
+ &d->ether.d_addr);
+ rte_ether_addr_copy(&p->vxlan.ether.sa,
+ &d->ether.s_addr);
+ d->ether.ether_type = rte_htons(RTE_ETHER_TYPE_VLAN);
/* VLAN */
d->vlan.vlan_tci = rte_htons(VLAN(p->vxlan.vlan.pcp,
p->vxlan.vlan.dei,
p->vxlan.vlan.vid));
- d->vlan.eth_proto = rte_htons(ETHER_TYPE_IPv4);
+ d->vlan.eth_proto = rte_htons(RTE_ETHER_TYPE_IPV4);
/* IPv4*/
d->ipv4.version_ihl = 0x45;
struct encap_vxlan_ipv4_data *d = data;
/* Ethernet */
- ether_addr_copy(&p->vxlan.ether.da, &d->ether.d_addr);
- ether_addr_copy(&p->vxlan.ether.sa, &d->ether.s_addr);
- d->ether.ether_type = rte_htons(ETHER_TYPE_IPv4);
+ rte_ether_addr_copy(&p->vxlan.ether.da,
+ &d->ether.d_addr);
+ rte_ether_addr_copy(&p->vxlan.ether.sa,
+ &d->ether.s_addr);
+ d->ether.ether_type = rte_htons(RTE_ETHER_TYPE_IPV4);
/* IPv4*/
d->ipv4.version_ihl = 0x45;
struct encap_vxlan_ipv6_vlan_data *d = data;
/* Ethernet */
- ether_addr_copy(&p->vxlan.ether.da, &d->ether.d_addr);
- ether_addr_copy(&p->vxlan.ether.sa, &d->ether.s_addr);
- d->ether.ether_type = rte_htons(ETHER_TYPE_VLAN);
+ rte_ether_addr_copy(&p->vxlan.ether.da,
+ &d->ether.d_addr);
+ rte_ether_addr_copy(&p->vxlan.ether.sa,
+ &d->ether.s_addr);
+ d->ether.ether_type = rte_htons(RTE_ETHER_TYPE_VLAN);
/* VLAN */
d->vlan.vlan_tci = rte_htons(VLAN(p->vxlan.vlan.pcp,
p->vxlan.vlan.dei,
p->vxlan.vlan.vid));
- d->vlan.eth_proto = rte_htons(ETHER_TYPE_IPv6);
+ d->vlan.eth_proto = rte_htons(RTE_ETHER_TYPE_IPV6);
/* IPv6*/
d->ipv6.vtc_flow = rte_htonl((6 << 28) |
struct encap_vxlan_ipv6_data *d = data;
/* Ethernet */
- ether_addr_copy(&p->vxlan.ether.da, &d->ether.d_addr);
- ether_addr_copy(&p->vxlan.ether.sa, &d->ether.s_addr);
- d->ether.ether_type = rte_htons(ETHER_TYPE_IPv6);
+ rte_ether_addr_copy(&p->vxlan.ether.da,
+ &d->ether.d_addr);
+ rte_ether_addr_copy(&p->vxlan.ether.sa,
+ &d->ether.s_addr);
+ d->ether.ether_type = rte_htons(RTE_ETHER_TYPE_IPV6);
/* IPv6*/
d->ipv6.vtc_flow = rte_htonl((6 << 28) |
case RTE_TABLE_ACTION_ENCAP_VXLAN:
return encap_vxlan_apply(data, p, cfg);
+ case RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE:
+ return encap_qinq_pppoe_apply(data, p);
+
default:
return -EINVAL;
}
ether_length = (uint16_t)mbuf->pkt_len;
ipv4_total_length = ether_length +
- (sizeof(struct vxlan_hdr) +
- sizeof(struct udp_hdr) +
- sizeof(struct ipv4_hdr));
+ (sizeof(struct rte_vxlan_hdr) +
+ sizeof(struct rte_udp_hdr) +
+ sizeof(struct rte_ipv4_hdr));
ipv4_hdr_cksum = encap_vxlan_ipv4_checksum_update(vxlan_tbl->ipv4.hdr_checksum,
rte_htons(ipv4_total_length));
udp_length = ether_length +
- (sizeof(struct vxlan_hdr) +
- sizeof(struct udp_hdr));
+ (sizeof(struct rte_vxlan_hdr) +
+ sizeof(struct rte_udp_hdr));
vxlan_pkt = encap(ether, vxlan_tbl, sizeof(*vxlan_tbl));
vxlan_pkt->ipv4.total_length = rte_htons(ipv4_total_length);
ether_length = (uint16_t)mbuf->pkt_len;
ipv4_total_length = ether_length +
- (sizeof(struct vxlan_hdr) +
- sizeof(struct udp_hdr) +
- sizeof(struct ipv4_hdr));
+ (sizeof(struct rte_vxlan_hdr) +
+ sizeof(struct rte_udp_hdr) +
+ sizeof(struct rte_ipv4_hdr));
ipv4_hdr_cksum = encap_vxlan_ipv4_checksum_update(vxlan_tbl->ipv4.hdr_checksum,
rte_htons(ipv4_total_length));
udp_length = ether_length +
- (sizeof(struct vxlan_hdr) +
- sizeof(struct udp_hdr));
+ (sizeof(struct rte_vxlan_hdr) +
+ sizeof(struct rte_udp_hdr));
vxlan_pkt = encap(ether, vxlan_tbl, sizeof(*vxlan_tbl));
vxlan_pkt->ipv4.total_length = rte_htons(ipv4_total_length);
ether_length = (uint16_t)mbuf->pkt_len;
ipv6_payload_length = ether_length +
- (sizeof(struct vxlan_hdr) +
- sizeof(struct udp_hdr));
+ (sizeof(struct rte_vxlan_hdr) +
+ sizeof(struct rte_udp_hdr));
udp_length = ether_length +
- (sizeof(struct vxlan_hdr) +
- sizeof(struct udp_hdr));
+ (sizeof(struct rte_vxlan_hdr) +
+ sizeof(struct rte_udp_hdr));
vxlan_pkt = encap(ether, vxlan_tbl, sizeof(*vxlan_tbl));
vxlan_pkt->ipv6.payload_len = rte_htons(ipv6_payload_length);
ether_length = (uint16_t)mbuf->pkt_len;
ipv6_payload_length = ether_length +
- (sizeof(struct vxlan_hdr) +
- sizeof(struct udp_hdr));
+ (sizeof(struct rte_vxlan_hdr) +
+ sizeof(struct rte_udp_hdr));
udp_length = ether_length +
- (sizeof(struct vxlan_hdr) +
- sizeof(struct udp_hdr));
+ (sizeof(struct rte_vxlan_hdr) +
+ sizeof(struct rte_udp_hdr));
vxlan_pkt = encap(ether, vxlan_tbl, sizeof(*vxlan_tbl));
vxlan_pkt->ipv6.payload_len = rte_htons(ipv6_payload_length);
case 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS:
{
struct encap_mpls_data *mpls = data;
- size_t size = sizeof(struct ether_hdr) +
+ size_t size = sizeof(struct rte_ether_hdr) +
mpls->mpls_count * 4;
encap(ip, data, size);
break;
}
+ case 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE:
+ {
+ struct encap_qinq_pppoe_data *qinq_pppoe =
+ encap(ip, data, sizeof(struct encap_qinq_pppoe_data));
+ qinq_pppoe->pppoe_ppp.length = rte_htons(total_length + 2);
+ mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) +
+ sizeof(struct encap_qinq_pppoe_data));
+ mbuf->pkt_len = mbuf->data_len = total_length +
+ sizeof(struct encap_qinq_pppoe_data);
+ break;
+ }
+
case 1LLU << RTE_TABLE_ACTION_ENCAP_VXLAN:
{
if (cfg->vxlan.ip_version)
struct nat_ipv4_data {
uint32_t addr;
uint16_t port;
-} __attribute__((__packed__));
+} __rte_packed;
struct nat_ipv6_data {
uint8_t addr[16];
uint16_t port;
-} __attribute__((__packed__));
+} __rte_packed;
static size_t
nat_data_size(struct rte_table_action_nat_config *nat __rte_unused,
}
static __rte_always_inline void
-pkt_ipv4_work_nat(struct ipv4_hdr *ip,
+pkt_ipv4_work_nat(struct rte_ipv4_hdr *ip,
struct nat_ipv4_data *data,
struct rte_table_action_nat_config *cfg)
{
if (cfg->source_nat) {
if (cfg->proto == 0x6) {
- struct tcp_hdr *tcp = (struct tcp_hdr *) &ip[1];
+ struct rte_tcp_hdr *tcp = (struct rte_tcp_hdr *) &ip[1];
uint16_t ip_cksum, tcp_cksum;
ip_cksum = nat_ipv4_checksum_update(ip->hdr_checksum,
tcp->src_port = data->port;
tcp->cksum = tcp_cksum;
} else {
- struct udp_hdr *udp = (struct udp_hdr *) &ip[1];
+ struct rte_udp_hdr *udp = (struct rte_udp_hdr *) &ip[1];
uint16_t ip_cksum, udp_cksum;
ip_cksum = nat_ipv4_checksum_update(ip->hdr_checksum,
}
} else {
if (cfg->proto == 0x6) {
- struct tcp_hdr *tcp = (struct tcp_hdr *) &ip[1];
+ struct rte_tcp_hdr *tcp = (struct rte_tcp_hdr *) &ip[1];
uint16_t ip_cksum, tcp_cksum;
ip_cksum = nat_ipv4_checksum_update(ip->hdr_checksum,
tcp->dst_port = data->port;
tcp->cksum = tcp_cksum;
} else {
- struct udp_hdr *udp = (struct udp_hdr *) &ip[1];
+ struct rte_udp_hdr *udp = (struct rte_udp_hdr *) &ip[1];
uint16_t ip_cksum, udp_cksum;
ip_cksum = nat_ipv4_checksum_update(ip->hdr_checksum,
}
static __rte_always_inline void
-pkt_ipv6_work_nat(struct ipv6_hdr *ip,
+pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
struct nat_ipv6_data *data,
struct rte_table_action_nat_config *cfg)
{
if (cfg->source_nat) {
if (cfg->proto == 0x6) {
- struct tcp_hdr *tcp = (struct tcp_hdr *) &ip[1];
+ struct rte_tcp_hdr *tcp = (struct rte_tcp_hdr *) &ip[1];
uint16_t tcp_cksum;
tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
tcp->src_port = data->port;
tcp->cksum = tcp_cksum;
} else {
- struct udp_hdr *udp = (struct udp_hdr *) &ip[1];
+ struct rte_udp_hdr *udp = (struct rte_udp_hdr *) &ip[1];
uint16_t udp_cksum;
udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
}
} else {
if (cfg->proto == 0x6) {
- struct tcp_hdr *tcp = (struct tcp_hdr *) &ip[1];
+ struct rte_tcp_hdr *tcp = (struct rte_tcp_hdr *) &ip[1];
uint16_t tcp_cksum;
tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
tcp->dst_port = data->port;
tcp->cksum = tcp_cksum;
} else {
- struct udp_hdr *udp = (struct udp_hdr *) &ip[1];
+ struct rte_udp_hdr *udp = (struct rte_udp_hdr *) &ip[1];
uint16_t udp_cksum;
udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
struct ttl_data {
uint32_t n_packets;
-} __attribute__((__packed__));
+} __rte_packed;
#define TTL_INIT(data, decrement) \
((data)->n_packets = (decrement) ? 1 : 0)
}
static __rte_always_inline uint64_t
-pkt_ipv4_work_ttl(struct ipv4_hdr *ip,
+pkt_ipv4_work_ttl(struct rte_ipv4_hdr *ip,
struct ttl_data *data)
{
uint32_t drop;
}
static __rte_always_inline uint64_t
-pkt_ipv6_work_ttl(struct ipv6_hdr *ip,
+pkt_ipv6_work_ttl(struct rte_ipv6_hdr *ip,
struct ttl_data *data)
{
uint32_t drop;
struct stats_data {
uint64_t n_packets;
uint64_t n_bytes;
-} __attribute__((__packed__));
+} __rte_packed;
static int
stats_apply(struct stats_data *data,
*/
struct time_data {
uint64_t time;
-} __attribute__((__packed__));
+} __rte_packed;
static int
time_apply(struct time_data *data,
/** Private data size to store cipher iv / aad. */
uint8_t iv_aad_data[32];
-} __attribute__((__packed__));
+} __rte_packed;
static int
sym_crypto_cfg_check(struct rte_table_action_sym_crypto_config *cfg)
rte_cryptodev_info_get(cdev_id, &dev_info);
- for (i = 0;; i++) {
+ for (i = 0; dev_info.capabilities[i].op != RTE_CRYPTO_OP_TYPE_UNDEFINED;
+ i++) {
cap = &dev_info.capabilities[i];
- if (!cap)
- break;
if (cap->sym.xform_type != xform->type)
continue;
return 0;
}
+/**
+ * RTE_TABLE_ACTION_TAG
+ */
+struct tag_data {
+ uint32_t tag;
+} __rte_packed;
+
+static int
+tag_apply(struct tag_data *data,
+ struct rte_table_action_tag_params *p)
+{
+ data->tag = p->tag;
+ return 0;
+}
+
+static __rte_always_inline void
+pkt_work_tag(struct rte_mbuf *mbuf,
+ struct tag_data *data)
+{
+ mbuf->hash.fdir.hi = data->tag;
+ mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+}
+
+static __rte_always_inline void
+pkt4_work_tag(struct rte_mbuf *mbuf0,
+ struct rte_mbuf *mbuf1,
+ struct rte_mbuf *mbuf2,
+ struct rte_mbuf *mbuf3,
+ struct tag_data *data0,
+ struct tag_data *data1,
+ struct tag_data *data2,
+ struct tag_data *data3)
+{
+ mbuf0->hash.fdir.hi = data0->tag;
+ mbuf1->hash.fdir.hi = data1->tag;
+ mbuf2->hash.fdir.hi = data2->tag;
+ mbuf3->hash.fdir.hi = data3->tag;
+
+ mbuf0->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+ mbuf1->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+ mbuf2->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+ mbuf3->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+}
+
+/**
+ * RTE_TABLE_ACTION_DECAP
+ */
+struct decap_data {
+ uint16_t n;
+} __rte_packed;
+
+static int
+decap_apply(struct decap_data *data,
+ struct rte_table_action_decap_params *p)
+{
+ data->n = p->n;
+ return 0;
+}
+
+static __rte_always_inline void
+pkt_work_decap(struct rte_mbuf *mbuf,
+ struct decap_data *data)
+{
+ uint16_t data_off = mbuf->data_off;
+ uint16_t data_len = mbuf->data_len;
+ uint32_t pkt_len = mbuf->pkt_len;
+ uint16_t n = data->n;
+
+ mbuf->data_off = data_off + n;
+ mbuf->data_len = data_len - n;
+ mbuf->pkt_len = pkt_len - n;
+}
+
+static __rte_always_inline void
+pkt4_work_decap(struct rte_mbuf *mbuf0,
+ struct rte_mbuf *mbuf1,
+ struct rte_mbuf *mbuf2,
+ struct rte_mbuf *mbuf3,
+ struct decap_data *data0,
+ struct decap_data *data1,
+ struct decap_data *data2,
+ struct decap_data *data3)
+{
+ uint16_t data_off0 = mbuf0->data_off;
+ uint16_t data_len0 = mbuf0->data_len;
+ uint32_t pkt_len0 = mbuf0->pkt_len;
+
+ uint16_t data_off1 = mbuf1->data_off;
+ uint16_t data_len1 = mbuf1->data_len;
+ uint32_t pkt_len1 = mbuf1->pkt_len;
+
+ uint16_t data_off2 = mbuf2->data_off;
+ uint16_t data_len2 = mbuf2->data_len;
+ uint32_t pkt_len2 = mbuf2->pkt_len;
+
+ uint16_t data_off3 = mbuf3->data_off;
+ uint16_t data_len3 = mbuf3->data_len;
+ uint32_t pkt_len3 = mbuf3->pkt_len;
+
+ uint16_t n0 = data0->n;
+ uint16_t n1 = data1->n;
+ uint16_t n2 = data2->n;
+ uint16_t n3 = data3->n;
+
+ mbuf0->data_off = data_off0 + n0;
+ mbuf0->data_len = data_len0 - n0;
+ mbuf0->pkt_len = pkt_len0 - n0;
+
+ mbuf1->data_off = data_off1 + n1;
+ mbuf1->data_len = data_len1 - n1;
+ mbuf1->pkt_len = pkt_len1 - n1;
+
+ mbuf2->data_off = data_off2 + n2;
+ mbuf2->data_len = data_len2 - n2;
+ mbuf2->pkt_len = pkt_len2 - n2;
+
+ mbuf3->data_off = data_off3 + n3;
+ mbuf3->data_len = data_len3 - n3;
+ mbuf3->pkt_len = pkt_len3 - n3;
+}
+
/**
* Action profile
*/
case RTE_TABLE_ACTION_STATS:
case RTE_TABLE_ACTION_TIME:
case RTE_TABLE_ACTION_SYM_CRYPTO:
+ case RTE_TABLE_ACTION_TAG:
+ case RTE_TABLE_ACTION_DECAP:
return 1;
default:
return 0;
case RTE_TABLE_ACTION_SYM_CRYPTO:
return (sizeof(struct sym_crypto_data));
+ case RTE_TABLE_ACTION_TAG:
+ return sizeof(struct tag_data);
+
+ case RTE_TABLE_ACTION_DECAP:
+ return sizeof(struct decap_data);
+
default:
return 0;
}
&action->cfg.sym_crypto,
action_params);
+ case RTE_TABLE_ACTION_TAG:
+ return tag_apply(action_data,
+ action_params);
+
+ case RTE_TABLE_ACTION_DECAP:
+ return decap_apply(action_data,
+ action_params);
+
default:
return -EINVAL;
}
&action->dscp_table.entry[i];
struct rte_table_action_dscp_table_entry *entry =
&table->entry[i];
- uint16_t queue_tc_color =
- MBUF_SCHED_QUEUE_TC_COLOR(entry->tc_queue_id,
- entry->tc_id,
- entry->color);
if ((dscp_mask & (1LLU << i)) == 0)
continue;
data->color = entry->color;
data->tc = entry->tc_id;
- data->queue_tc_color = queue_tc_color;
+ data->tc_queue = entry->tc_queue_id;
}
return 0;
if ((tc_mask & (1 << i)) == 0)
continue;
- dst->n_packets[e_RTE_METER_GREEN] =
- mtr_trtcm_data_stats_get(src, e_RTE_METER_GREEN);
+ dst->n_packets[RTE_COLOR_GREEN] =
+ mtr_trtcm_data_stats_get(src, RTE_COLOR_GREEN);
- dst->n_packets[e_RTE_METER_YELLOW] =
- mtr_trtcm_data_stats_get(src, e_RTE_METER_YELLOW);
+ dst->n_packets[RTE_COLOR_YELLOW] =
+ mtr_trtcm_data_stats_get(src, RTE_COLOR_YELLOW);
- dst->n_packets[e_RTE_METER_RED] =
- mtr_trtcm_data_stats_get(src, e_RTE_METER_RED);
+ dst->n_packets[RTE_COLOR_RED] =
+ mtr_trtcm_data_stats_get(src, RTE_COLOR_RED);
dst->n_packets_valid = 1;
dst->n_bytes_valid = 0;
if ((tc_mask & (1 << i)) == 0)
continue;
- mtr_trtcm_data_stats_reset(src, e_RTE_METER_GREEN);
- mtr_trtcm_data_stats_reset(src, e_RTE_METER_YELLOW);
- mtr_trtcm_data_stats_reset(src, e_RTE_METER_RED);
+ mtr_trtcm_data_stats_reset(src, RTE_COLOR_GREEN);
+ mtr_trtcm_data_stats_reset(src, RTE_COLOR_YELLOW);
+ mtr_trtcm_data_stats_reset(src, RTE_COLOR_RED);
}
uint16_t total_length;
if (cfg->common.ip_version) {
- struct ipv4_hdr *hdr = ip;
+ struct rte_ipv4_hdr *hdr = ip;
dscp = hdr->type_of_service >> 2;
total_length = rte_ntohs(hdr->total_length);
} else {
- struct ipv6_hdr *hdr = ip;
+ struct rte_ipv6_hdr *hdr = ip;
dscp = (rte_ntohl(hdr->vtc_flow) & 0x0F600000) >> 18;
- total_length =
- rte_ntohs(hdr->payload_len) + sizeof(struct ipv6_hdr);
+ total_length = rte_ntohs(hdr->payload_len) +
+ sizeof(struct rte_ipv6_hdr);
}
if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_LB)) {
dscp);
}
+ if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_DECAP)) {
+ void *data = action_data_get(table_entry,
+ action,
+ RTE_TABLE_ACTION_DECAP);
+
+ pkt_work_decap(mbuf, data);
+ }
+
if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_ENCAP)) {
void *data =
action_data_get(table_entry, action, RTE_TABLE_ACTION_ENCAP);
ip_offset);
}
+ if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) {
+ void *data = action_data_get(table_entry,
+ action,
+ RTE_TABLE_ACTION_TAG);
+
+ pkt_work_tag(mbuf, data);
+ }
+
return drop_mask;
}
uint16_t total_length0, total_length1, total_length2, total_length3;
if (cfg->common.ip_version) {
- struct ipv4_hdr *hdr0 = ip0;
- struct ipv4_hdr *hdr1 = ip1;
- struct ipv4_hdr *hdr2 = ip2;
- struct ipv4_hdr *hdr3 = ip3;
+ struct rte_ipv4_hdr *hdr0 = ip0;
+ struct rte_ipv4_hdr *hdr1 = ip1;
+ struct rte_ipv4_hdr *hdr2 = ip2;
+ struct rte_ipv4_hdr *hdr3 = ip3;
dscp0 = hdr0->type_of_service >> 2;
dscp1 = hdr1->type_of_service >> 2;
total_length2 = rte_ntohs(hdr2->total_length);
total_length3 = rte_ntohs(hdr3->total_length);
} else {
- struct ipv6_hdr *hdr0 = ip0;
- struct ipv6_hdr *hdr1 = ip1;
- struct ipv6_hdr *hdr2 = ip2;
- struct ipv6_hdr *hdr3 = ip3;
+ struct rte_ipv6_hdr *hdr0 = ip0;
+ struct rte_ipv6_hdr *hdr1 = ip1;
+ struct rte_ipv6_hdr *hdr2 = ip2;
+ struct rte_ipv6_hdr *hdr3 = ip3;
dscp0 = (rte_ntohl(hdr0->vtc_flow) & 0x0F600000) >> 18;
dscp1 = (rte_ntohl(hdr1->vtc_flow) & 0x0F600000) >> 18;
dscp2 = (rte_ntohl(hdr2->vtc_flow) & 0x0F600000) >> 18;
dscp3 = (rte_ntohl(hdr3->vtc_flow) & 0x0F600000) >> 18;
- total_length0 =
- rte_ntohs(hdr0->payload_len) + sizeof(struct ipv6_hdr);
- total_length1 =
- rte_ntohs(hdr1->payload_len) + sizeof(struct ipv6_hdr);
- total_length2 =
- rte_ntohs(hdr2->payload_len) + sizeof(struct ipv6_hdr);
- total_length3 =
- rte_ntohs(hdr3->payload_len) + sizeof(struct ipv6_hdr);
+ total_length0 = rte_ntohs(hdr0->payload_len) +
+ sizeof(struct rte_ipv6_hdr);
+ total_length1 = rte_ntohs(hdr1->payload_len) +
+ sizeof(struct rte_ipv6_hdr);
+ total_length2 = rte_ntohs(hdr2->payload_len) +
+ sizeof(struct rte_ipv6_hdr);
+ total_length3 = rte_ntohs(hdr3->payload_len) +
+ sizeof(struct rte_ipv6_hdr);
}
if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_LB)) {
dscp3);
}
+ if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_DECAP)) {
+ void *data0 = action_data_get(table_entry0,
+ action,
+ RTE_TABLE_ACTION_DECAP);
+ void *data1 = action_data_get(table_entry1,
+ action,
+ RTE_TABLE_ACTION_DECAP);
+ void *data2 = action_data_get(table_entry2,
+ action,
+ RTE_TABLE_ACTION_DECAP);
+ void *data3 = action_data_get(table_entry3,
+ action,
+ RTE_TABLE_ACTION_DECAP);
+
+ pkt4_work_decap(mbuf0, mbuf1, mbuf2, mbuf3,
+ data0, data1, data2, data3);
+ }
+
if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_ENCAP)) {
void *data0 =
action_data_get(table_entry0, action, RTE_TABLE_ACTION_ENCAP);
ip_offset);
}
+ if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) {
+ void *data0 = action_data_get(table_entry0,
+ action,
+ RTE_TABLE_ACTION_TAG);
+ void *data1 = action_data_get(table_entry1,
+ action,
+ RTE_TABLE_ACTION_TAG);
+ void *data2 = action_data_get(table_entry2,
+ action,
+ RTE_TABLE_ACTION_TAG);
+ void *data3 = action_data_get(table_entry3,
+ action,
+ RTE_TABLE_ACTION_TAG);
+
+ pkt4_work_tag(mbuf0, mbuf1, mbuf2, mbuf3,
+ data0, data1, data2, data3);
+ }
+
return drop_mask0 |
(drop_mask1 << 1) |
(drop_mask2 << 2) |