@@ -19,6 +19,8 @@
#define CLS_DEFAULT_DADDR "10.0.0.100/32"
#define CLS_DEFAULT_SPORT 1024
#define CLS_DEFAULT_DPORT 2048
+#define CLS_DEFAULT_DMAC 0x010203040506
+#define CLS_DEFAULT_SMAC 0x060504030201
/* Config values for Error CoS */
#define TEST_ERROR 1
@@ -76,6 +78,8 @@ void classification_test_pmr_term_tcp_sport(void);
void classification_test_pmr_term_udp_dport(void);
void classification_test_pmr_term_udp_sport(void);
void classification_test_pmr_term_ipproto(void);
+void classification_test_pmr_term_dmac(void);
+void classification_test_pmr_term_packet_len(void);
/* test arrays: */
extern odp_testinfo_t classification_suite_basic[];
@@ -193,21 +193,35 @@ odp_pool_t pool_create(const char *poolname)
odp_packet_t create_packet(odp_pool_t pool, bool vlan,
odp_atomic_u32_t *seq, bool flag_udp)
{
+ return create_packet_len(pool, vlan, seq, flag_udp, 0);
+}
+
+odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
+ odp_atomic_u32_t *seq, bool flag_udp,
+ uint16_t len)
+{
uint32_t seqno;
odph_ethhdr_t *ethhdr;
odph_udphdr_t *udp;
odph_tcphdr_t *tcp;
odph_ipv4hdr_t *ip;
- uint8_t payload_len;
- char src_mac[ODPH_ETHADDR_LEN] = {0};
- char dst_mac[ODPH_ETHADDR_LEN] = {0};
+ uint16_t payload_len;
+ uint64_t src_mac = CLS_DEFAULT_SMAC;
+ uint64_t dst_mac = CLS_DEFAULT_DMAC;
+ uint64_t dst_mac_be;
uint32_t addr = 0;
uint32_t mask;
int offset;
odp_packet_t pkt;
int packet_len = 0;
- payload_len = sizeof(cls_test_packet_t);
+ /* 48 bit ethernet address needs to be left shifted for proper
+ value after changing to be*/
+ dst_mac_be = odp_cpu_to_be_64(dst_mac);
+ if (dst_mac != dst_mac_be)
+ dst_mac_be = dst_mac_be >> (64 - 8 * ODPH_ETHADDR_LEN);
+
+ payload_len = sizeof(cls_test_packet_t) + len;
packet_len += ODPH_ETHHDR_LEN;
packet_len += ODPH_IPV4HDR_LEN;
if (flag_udp)
@@ -226,8 +240,8 @@ odp_packet_t create_packet(odp_pool_t pool, bool vlan,
offset = 0;
odp_packet_l2_offset_set(pkt, offset);
ethhdr = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
- memcpy(ethhdr->src.addr, src_mac, ODPH_ETHADDR_LEN);
- memcpy(ethhdr->dst.addr, dst_mac, ODPH_ETHADDR_LEN);
+ memcpy(ethhdr->src.addr, &src_mac, ODPH_ETHADDR_LEN);
+ memcpy(ethhdr->dst.addr, &dst_mac_be, ODPH_ETHADDR_LEN);
offset += sizeof(odph_ethhdr_t);
if (vlan) {
/* Default vlan header */
@@ -663,6 +663,211 @@ void classification_test_pmr_term_ipproto(void)
odp_pktio_close(pktio);
}
+void classification_test_pmr_term_dmac(void)
+{
+ odp_packet_t pkt;
+ uint32_t seqno;
+ uint64_t val;
+ uint64_t mask;
+ int retval;
+ odp_pktio_t pktio;
+ odp_queue_t queue;
+ odp_queue_t retqueue;
+ odp_queue_t default_queue;
+ odp_cos_t default_cos;
+ odp_pool_t default_pool;
+ odp_pool_t pool;
+ odp_pool_t recvpool;
+ odp_pmr_t pmr;
+ odp_cos_t cos;
+ char cosname[ODP_COS_NAME_LEN];
+ odp_cls_cos_param_t cls_param;
+ odp_pmr_match_t match;
+ odph_ethhdr_t *eth;
+
+ val = CLS_DEFAULT_DMAC; /* 48 bit Ethernet Mac address */
+ mask = 0xffffffffffff;
+ seqno = 0;
+
+ pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
+ CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
+ retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
+ CU_ASSERT(retval == 0);
+
+ match.term = ODP_PMR_DMAC;
+ match.val = &val;
+ match.mask = &mask;
+ match.val_sz = ODPH_ETHADDR_LEN;
+
+ pmr = odp_pmr_create(&match);
+ CU_ASSERT(pmr != ODP_PMR_INVAL);
+
+ queue = queue_create("dmac", true);
+ CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);
+
+ pool = pool_create("dmac");
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+ sprintf(cosname, "dmac");
+ odp_cls_cos_param_init(&cls_param);
+ cls_param.pool = pool;
+ cls_param.queue = queue;
+ cls_param.drop_policy = ODP_COS_DROP_POOL;
+
+ cos = odp_cls_cos_create(cosname, &cls_param);
+ CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
+
+ retval = odp_pktio_pmr_cos(pmr, pktio, cos);
+ CU_ASSERT(retval == 0);
+
+ configure_default_cos(pktio, &default_cos,
+ &default_queue, &default_pool);
+ pkt = create_packet(pkt_pool, false, &seq, true);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ seqno = cls_pkt_get_seq(pkt);
+ CU_ASSERT(seqno != TEST_SEQ_INVALID);
+
+ enqueue_pktio_interface(pkt, pktio);
+
+ pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ CU_ASSERT(seqno == cls_pkt_get_seq(pkt));
+ recvpool = odp_packet_pool(pkt);
+ CU_ASSERT(recvpool == pool);
+ CU_ASSERT(retqueue == queue);
+ odp_packet_free(pkt);
+
+ /* Other packets delivered to default queue */
+ pkt = create_packet(pkt_pool, false, &seq, false);
+ eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
+ memset(eth->dst.addr, 0, ODPH_ETHADDR_LEN);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ seqno = cls_pkt_get_seq(pkt);
+ CU_ASSERT(seqno != TEST_SEQ_INVALID);
+
+ enqueue_pktio_interface(pkt, pktio);
+
+ pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ CU_ASSERT(seqno == cls_pkt_get_seq(pkt));
+ recvpool = odp_packet_pool(pkt);
+ CU_ASSERT(recvpool == default_pool);
+ CU_ASSERT(retqueue == default_queue);
+
+ odp_cos_destroy(cos);
+ odp_cos_destroy(default_cos);
+ odp_pmr_destroy(pmr);
+ odp_packet_free(pkt);
+ destroy_inq(pktio);
+ odp_pool_destroy(default_pool);
+ odp_pool_destroy(pool);
+ odp_queue_destroy(queue);
+ odp_queue_destroy(default_queue);
+ odp_pktio_close(pktio);
+}
+
+void classification_test_pmr_term_packet_len(void)
+{
+ odp_packet_t pkt;
+ uint32_t seqno;
+ uint16_t val;
+ uint16_t mask;
+ int retval;
+ odp_pktio_t pktio;
+ odp_queue_t queue;
+ odp_queue_t retqueue;
+ odp_queue_t default_queue;
+ odp_cos_t default_cos;
+ odp_pool_t default_pool;
+ odp_pool_t pool;
+ odp_pool_t recvpool;
+ odp_pmr_t pmr;
+ odp_cos_t cos;
+ char cosname[ODP_COS_NAME_LEN];
+ odp_cls_cos_param_t cls_param;
+ odp_pmr_match_t match;
+
+ val = 1024;
+ /*Mask value will match any packet of length 1000 - 1099*/
+ mask = 0xff00;
+ seqno = 0;
+
+ pktio = create_pktio(ODP_QUEUE_TYPE_SCHED);
+ CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
+ retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED);
+ CU_ASSERT(retval == 0);
+
+ match.term = ODP_PMR_LEN;
+ match.val = &val;
+ match.mask = &mask;
+ match.val_sz = sizeof(val);
+
+ pmr = odp_pmr_create(&match);
+ CU_ASSERT(pmr != ODP_PMR_INVAL);
+
+ queue = queue_create("packet_len", true);
+ CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);
+
+ pool = pool_create("packet_len");
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+ sprintf(cosname, "packet_len");
+ odp_cls_cos_param_init(&cls_param);
+ cls_param.pool = pool;
+ cls_param.queue = queue;
+ cls_param.drop_policy = ODP_COS_DROP_POOL;
+
+ cos = odp_cls_cos_create(cosname, &cls_param);
+ CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
+
+ retval = odp_pktio_pmr_cos(pmr, pktio, cos);
+ CU_ASSERT(retval == 0);
+
+ configure_default_cos(pktio, &default_cos,
+ &default_queue, &default_pool);
+ /* create packet of payload length 1024 */
+ pkt = create_packet_len(pkt_pool, false, &seq, true, 1024);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ seqno = cls_pkt_get_seq(pkt);
+ CU_ASSERT(seqno != TEST_SEQ_INVALID);
+
+ enqueue_pktio_interface(pkt, pktio);
+
+ pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ CU_ASSERT(seqno == cls_pkt_get_seq(pkt));
+ recvpool = odp_packet_pool(pkt);
+ CU_ASSERT(recvpool == pool);
+ CU_ASSERT(retqueue == queue);
+ odp_packet_free(pkt);
+
+ /* Other packets delivered to default queue */
+ pkt = create_packet(pkt_pool, false, &seq, false);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ seqno = cls_pkt_get_seq(pkt);
+ CU_ASSERT(seqno != TEST_SEQ_INVALID);
+
+ enqueue_pktio_interface(pkt, pktio);
+
+ pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ CU_ASSERT(seqno == cls_pkt_get_seq(pkt));
+ recvpool = odp_packet_pool(pkt);
+ CU_ASSERT(recvpool == default_pool);
+ CU_ASSERT(retqueue == default_queue);
+
+ odp_cos_destroy(cos);
+ odp_cos_destroy(default_cos);
+ odp_pmr_destroy(pmr);
+ odp_packet_free(pkt);
+ destroy_inq(pktio);
+ odp_pool_destroy(default_pool);
+ odp_pool_destroy(pool);
+ odp_queue_destroy(queue);
+ odp_queue_destroy(default_queue);
+ odp_pktio_close(pktio);
+}
+
static void classification_test_pmr_pool_set(void)
{
odp_packet_t pkt;
@@ -955,8 +1160,10 @@ odp_testinfo_t classification_suite_pmr[] = {
ODP_TEST_INFO(classification_test_pmr_term_udp_dport),
ODP_TEST_INFO(classification_test_pmr_term_udp_sport),
ODP_TEST_INFO(classification_test_pmr_term_ipproto),
+ ODP_TEST_INFO(classification_test_pmr_term_dmac),
ODP_TEST_INFO(classification_test_pmr_pool_set),
ODP_TEST_INFO(classification_test_pmr_queue_set),
ODP_TEST_INFO(classification_test_pmr_term_daddr),
+ ODP_TEST_INFO(classification_test_pmr_term_packet_len),
ODP_TEST_INFO_NULL,
};
@@ -22,6 +22,9 @@ int classification_suite_pmr_init(void);
odp_packet_t create_packet(odp_pool_t pool, bool vlan,
odp_atomic_u32_t *seq, bool udp);
+odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
+ odp_atomic_u32_t *seq, bool flag_udp,
+ uint16_t len);
int cls_pkt_set_seq(odp_packet_t pkt);
uint32_t cls_pkt_get_seq(odp_packet_t pkt);
odp_pktio_t create_pktio(odp_queue_type_t q_type);
Fixes https://bugs.linaro.org/show_bug.cgi?id=1541 https://bugs.linaro.org/show_bug.cgi?id=1834 Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> --- test/validation/classification/classification.h | 4 + .../classification/odp_classification_common.c | 26 ++- .../classification/odp_classification_test_pmr.c | 207 +++++++++++++++++++++ .../classification/odp_classification_testsuites.h | 3 + 4 files changed, 234 insertions(+), 6 deletions(-)