diff mbox

[3/3] validation: pktio: add mac, promisc and mtu tests

Message ID 1418856112-8589-4-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Dec. 17, 2014, 10:41 p.m. UTC
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 test/validation/odp_pktio.c | 105 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 96 insertions(+), 9 deletions(-)

Comments

Bill Fischofer Dec. 18, 2014, 3:22 a.m. UTC | #1
On Wed, Dec 17, 2014 at 6:30 PM, Stuart Haslam <stuart.haslam@arm.com>
wrote:
>
> On Wed, Dec 17, 2014 at 10:41:52PM +0000, Maxim Uvarov wrote:
> > Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> > ---
> >  test/validation/odp_pktio.c | 105
> ++++++++++++++++++++++++++++++++++++++++----
> >  1 file changed, 96 insertions(+), 9 deletions(-)
> >
> > diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
> > index 0ba9938..02c4a7b 100644
> > --- a/test/validation/odp_pktio.c
> > +++ b/test/validation/odp_pktio.c
> > @@ -398,6 +398,90 @@ static void test_odp_pktio_sched_multi(void)
> >       pktio_test_txrx(ODP_QUEUE_TYPE_SCHED, 4);
> >  }
> >
> > +static void pktio_test_mtu(void)
> > +{
> > +     int i;
> > +     int ret;
> > +     int def;
> > +     odp_pktio_t pktio = create_pktio(iface_name[0]);
> > +
> > +     printf("testing mtu for %s\n", iface_name[0]);
>
> This printf isn't needed, cunit tells you which test is being run, same
> with the others below.
>
> > +
> > +     def = odp_pktio_mtu(pktio);
> > +     CU_ASSERT(def > 0);
> > +
> > +     for (i = 9000; i > 100; i /= 2) {
>
> I don't think support for jumbo frames should be mandatory.
>
>
I can't think of any 1Gb or higher NIC/SoC that doesn't support jumbo
frames.  This is pretty standard for higher data rate I/O these days, so no
harm in verifying that here.


> > +             printf(" %d ", i);
> > +
> > +             ret = odp_pktio_set_mtu(pktio, i);
> > +             CU_ASSERT(0 == ret);
> > +
> > +             ret = odp_pktio_mtu(pktio);
> > +             CU_ASSERT(i == ret);
> > +     }
> > +
>
> This is only really testing that the APIs can be called without blowing
> up, to test it properly you need to send packets and check their size is
> limited to the MTU. That can be added later though.
>
> > +     ret = odp_pktio_set_mtu(pktio, def);
> > +     CU_ASSERT(0 == ret);
> > +
> > +     ret = odp_pktio_close(pktio);
> > +     CU_ASSERT(ret == 0);
> > +
> > +     return;
> > +}
> > +
> > +static void pktio_test_promisc(void)
> > +{
> > +     int ret;
> > +     odp_pktio_t pktio = create_pktio(iface_name[0]);
> > +
> > +     printf("testing promisc for %s\n", iface_name[0]);
> > +
> > +     ret = odp_pktio_promisc_mode_set(pktio, 1);
> > +     CU_ASSERT(0 == ret);
> > +
> > +     /* Check */
> > +     ret = odp_pktio_promisc_mode(pktio);
> > +     CU_ASSERT(1 == ret);
> > +
> > +     ret = odp_pktio_promisc_mode_set(pktio, 0);
> > +     CU_ASSERT(0 == ret);
> > +
> > +     /* Check */
> > +     ret = odp_pktio_promisc_mode(pktio);
> > +     CU_ASSERT(0 == ret);
> > +
>
> Not actually checking that enabling/disabling promiscuous mode actually
> does anything. Again could be added later.
>
> > +     ret = odp_pktio_close(pktio);
> > +     CU_ASSERT(ret == 0);
> > +
> > +     return;
> > +}
> > +
> > +static void pktio_test_mac(void)
> > +{
> > +     unsigned char mac_addr[ODPH_ETHADDR_LEN];
> > +     size_t mac_len;
> > +     int ret;
> > +     odp_pktio_t pktio = create_pktio(iface_name[0]);
> > +
> > +     printf("testing mac for %s\n", iface_name[0]);
> > +
> > +     mac_len = odp_pktio_mac_addr(pktio, mac_addr, ODPH_ETHADDR_LEN);
> > +     CU_ASSERT(ODPH_ETHADDR_LEN == mac_len);
> > +
> > +     printf(" %X:%X:%X:%X:%X:%X ",
> > +            mac_addr[0], mac_addr[1], mac_addr[2],
> > +            mac_addr[3], mac_addr[4], mac_addr[5]);
> > +
> > +     /* Fail case */
> > +     mac_len = odp_pktio_mac_addr(pktio, mac_addr, 2);
> > +     CU_ASSERT(0 == mac_len);
> > +
> > +     ret = odp_pktio_close(pktio);
> > +     CU_ASSERT(ret == 0);
> > +
> > +     return;
> > +}
> > +
> >  static void test_odp_pktio_open(void)
> >  {
> >       odp_pktio_t pktio[2];
> > @@ -472,18 +556,21 @@ static int init_pktio_suite(void)
> >  }
> >
> >  CU_TestInfo pktio_tests[] = {
> > -     {"pktio open",         test_odp_pktio_open},
> > -     {"pktio close",        test_odp_pktio_close},
> > -     {"pktio inq",          test_odp_pktio_inq},
> > -     {"pktio outq",         test_odp_pktio_outq},
> > -     {"pktio poll queues",  test_odp_pktio_poll_queue},
> > -     {"pktio poll multi",   test_odp_pktio_poll_multi},
> > -     {"pktio sched queues", test_odp_pktio_sched_queue},
> > -     {"pktio sched multi",  test_odp_pktio_sched_multi},
> > +     {"pktio open",          test_odp_pktio_open},
> > +     {"pktio close",         test_odp_pktio_close},
> > +     {"pktio inq",           test_odp_pktio_inq},
> > +     {"pktio outq",          test_odp_pktio_outq},
> > +     {"pktio poll queues",   test_odp_pktio_poll_queue},
> > +     {"pktio poll multi",    test_odp_pktio_poll_multi},
> > +     {"pktio sched queues",  test_odp_pktio_sched_queue},
> > +     {"pktio sched multi",   test_odp_pktio_sched_multi},
> > +     {"pktio mtu",           pktio_test_mtu},
> > +     {"pktio promisc mode",  pktio_test_promisc},
> > +     {"pktio mac",           pktio_test_mac},
> >       CU_TEST_INFO_NULL
> >  };
> >
> >  CU_SuiteInfo odp_testsuites[] = {
> > -     {"odp_pktio", init_pktio_suite, NULL, NULL, NULL, pktio_tests},
> > +     {"Packet I/O", init_pktio_suite, NULL, NULL, NULL, pktio_tests},
> >       CU_SUITE_INFO_NULL
> >  };
> > --
> > 1.8.5.1.163.gd7aced9
> >
>
> --
> Stuart.
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Dec. 18, 2014, 9:50 a.m. UTC | #2
On 12/18/2014 12:42 PM, Stuart Haslam wrote:
> On Thu, Dec 18, 2014 at 03:22:29AM +0000, Bill Fischofer wrote:
>>
>> On Wed, Dec 17, 2014 at 6:30 PM, Stuart Haslam <stuart.haslam@arm.com<mailto:stuart.haslam@arm.com>> wrote:
>> On Wed, Dec 17, 2014 at 10:41:52PM +0000, Maxim Uvarov wrote:
>>> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org<mailto:maxim.uvarov@linaro.org>>
>>> ---
>>>   test/validation/odp_pktio.c | 105 ++++++++++++++++++++++++++++++++++++++++----
>>>   1 file changed, 96 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
>>> index 0ba9938..02c4a7b 100644
>>> --- a/test/validation/odp_pktio.c
>>> +++ b/test/validation/odp_pktio.c
>>> @@ -398,6 +398,90 @@ static void test_odp_pktio_sched_multi(void)
>>>        pktio_test_txrx(ODP_QUEUE_TYPE_SCHED, 4);
>>>   }
>>>
>>> +static void pktio_test_mtu(void)
>>> +{
>>> +     int i;
>>> +     int ret;
>>> +     int def;
>>> +     odp_pktio_t pktio = create_pktio(iface_name[0]);
>>> +
>>> +     printf("testing mtu for %s\n", iface_name[0]);
>> This printf isn't needed, cunit tells you which test is being run, same
>> with the others below.
>>
>>> +
>>> +     def = odp_pktio_mtu(pktio);
>>> +     CU_ASSERT(def > 0);
>>> +
>>> +     for (i = 9000; i > 100; i /= 2) {
>> I don't think support for jumbo frames should be mandatory.
>>
>>
>> I can't think of any 1Gb or higher NIC/SoC that doesn't support jumbo frames.  This is pretty standard for higher data rate I/O these days, so no harm in verifying that here.
>>
> I agree this is pretty standard on a "real" interface, but I was thinking
> more about on a development platform. The interface on my TC2 doesn't
> support >1500, nor does my beaglebone black, does that mean they can't
> support ODP? Obviously they aren't really target platforms but they
> would pass all other unit tests.
>
> This test isn't really intended to check which MTU values are supported,
> just that the API allows it to be configured. Without some other API to
> discover the capabilities of the interface (which we do need) I think
> it's better to stay within the safe zone <=1500, or change the behaviour
> above 1500 to not fail an assertion.
>
I can use <= 1500 for CU_ASSERT and print other values just in test output
if they are supported or not. Does it make any sense?

Maxim.
Maxim Uvarov Dec. 18, 2014, 10:30 a.m. UTC | #3
On 12/18/2014 12:42 PM, Stuart Haslam wrote:
>> +static void pktio_test_mtu(void)
>> > >+{
>> > >+     int i;
>> > >+     int ret;
>> > >+     int def;
>> > >+     odp_pktio_t pktio = create_pktio(iface_name[0]);
>> > >+
>> > >+     printf("testing mtu for %s\n", iface_name[0]);
> >
> >This printf isn't needed, cunit tells you which test is being run, same
> >with the others below.
I wanted to print pktio name on which testing is done.

Maxim.
Maxim Uvarov Dec. 18, 2014, 11:11 a.m. UTC | #4
On 12/18/2014 01:43 PM, Stuart Haslam wrote:
> On Thu, Dec 18, 2014 at 10:30:28AM +0000, Maxim Uvarov wrote:
>> On 12/18/2014 12:42 PM, Stuart Haslam wrote:
>>>> +static void pktio_test_mtu(void)
>>>>>> +{
>>>>>> +     int i;
>>>>>> +     int ret;
>>>>>> +     int def;
>>>>>> +     odp_pktio_t pktio = create_pktio(iface_name[0]);
>>>>>> +
>>>>>> +     printf("testing mtu for %s\n", iface_name[0]);
>>>> This printf isn't needed, cunit tells you which test is being run, same
>>>> with the others below.
>> I wanted to print pktio name on which testing is done.
>>
>> Maxim.
>>
> There's a single print in init_pktio_suite() that prints the interface
> name(s) used for all of the tests.
>
Agree, remove that lines.

Maxim.
Bill Fischofer Dec. 18, 2014, 11:23 a.m. UTC | #5
Stuart: Agree on the need for interface capability inquiry.  Perhaps an
odp_pktio_info_t struct can be defined that is returned by an
odp_pktio_info() call?  That would be consistent with similar syntax we're
using for other things (shm, buffer pools).  A max_mtu field would be part
of this struct which the test could then use.

Petri: We should discuss the sort of needs applications have in this area
as part of the pktio API finialization.

On Thu, Dec 18, 2014 at 5:11 AM, Maxim Uvarov <maxim.uvarov@linaro.org>
wrote:
>
> On 12/18/2014 01:43 PM, Stuart Haslam wrote:
>
>> On Thu, Dec 18, 2014 at 10:30:28AM +0000, Maxim Uvarov wrote:
>>
>>> On 12/18/2014 12:42 PM, Stuart Haslam wrote:
>>>
>>>> +static void pktio_test_mtu(void)
>>>>>
>>>>>> +{
>>>>>>> +     int i;
>>>>>>> +     int ret;
>>>>>>> +     int def;
>>>>>>> +     odp_pktio_t pktio = create_pktio(iface_name[0]);
>>>>>>> +
>>>>>>> +     printf("testing mtu for %s\n", iface_name[0]);
>>>>>>>
>>>>>> This printf isn't needed, cunit tells you which test is being run,
>>>>> same
>>>>> with the others below.
>>>>>
>>>> I wanted to print pktio name on which testing is done.
>>>
>>> Maxim.
>>>
>>>  There's a single print in init_pktio_suite() that prints the interface
>> name(s) used for all of the tests.
>>
>>  Agree, remove that lines.
>
> Maxim.
>
diff mbox

Patch

diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
index 0ba9938..02c4a7b 100644
--- a/test/validation/odp_pktio.c
+++ b/test/validation/odp_pktio.c
@@ -398,6 +398,90 @@  static void test_odp_pktio_sched_multi(void)
 	pktio_test_txrx(ODP_QUEUE_TYPE_SCHED, 4);
 }
 
+static void pktio_test_mtu(void)
+{
+	int i;
+	int ret;
+	int def;
+	odp_pktio_t pktio = create_pktio(iface_name[0]);
+
+	printf("testing mtu for %s\n", iface_name[0]);
+
+	def = odp_pktio_mtu(pktio);
+	CU_ASSERT(def > 0);
+
+	for (i = 9000; i > 100; i /= 2) {
+		printf(" %d ", i);
+
+		ret = odp_pktio_set_mtu(pktio, i);
+		CU_ASSERT(0 == ret);
+
+		ret = odp_pktio_mtu(pktio);
+		CU_ASSERT(i == ret);
+	}
+
+	ret = odp_pktio_set_mtu(pktio, def);
+	CU_ASSERT(0 == ret);
+
+	ret = odp_pktio_close(pktio);
+	CU_ASSERT(ret == 0);
+
+	return;
+}
+
+static void pktio_test_promisc(void)
+{
+	int ret;
+	odp_pktio_t pktio = create_pktio(iface_name[0]);
+
+	printf("testing promisc for %s\n", iface_name[0]);
+
+	ret = odp_pktio_promisc_mode_set(pktio, 1);
+	CU_ASSERT(0 == ret);
+
+	/* Check */
+	ret = odp_pktio_promisc_mode(pktio);
+	CU_ASSERT(1 == ret);
+
+	ret = odp_pktio_promisc_mode_set(pktio, 0);
+	CU_ASSERT(0 == ret);
+
+	/* Check */
+	ret = odp_pktio_promisc_mode(pktio);
+	CU_ASSERT(0 == ret);
+
+	ret = odp_pktio_close(pktio);
+	CU_ASSERT(ret == 0);
+
+	return;
+}
+
+static void pktio_test_mac(void)
+{
+	unsigned char mac_addr[ODPH_ETHADDR_LEN];
+	size_t mac_len;
+	int ret;
+	odp_pktio_t pktio = create_pktio(iface_name[0]);
+
+	printf("testing mac for %s\n", iface_name[0]);
+
+	mac_len = odp_pktio_mac_addr(pktio, mac_addr, ODPH_ETHADDR_LEN);
+	CU_ASSERT(ODPH_ETHADDR_LEN == mac_len);
+
+	printf(" %X:%X:%X:%X:%X:%X ",
+	       mac_addr[0], mac_addr[1], mac_addr[2],
+	       mac_addr[3], mac_addr[4], mac_addr[5]);
+
+	/* Fail case */
+	mac_len = odp_pktio_mac_addr(pktio, mac_addr, 2);
+	CU_ASSERT(0 == mac_len);
+
+	ret = odp_pktio_close(pktio);
+	CU_ASSERT(ret == 0);
+
+	return;
+}
+
 static void test_odp_pktio_open(void)
 {
 	odp_pktio_t pktio[2];
@@ -472,18 +556,21 @@  static int init_pktio_suite(void)
 }
 
 CU_TestInfo pktio_tests[] = {
-	{"pktio open",         test_odp_pktio_open},
-	{"pktio close",        test_odp_pktio_close},
-	{"pktio inq",          test_odp_pktio_inq},
-	{"pktio outq",         test_odp_pktio_outq},
-	{"pktio poll queues",  test_odp_pktio_poll_queue},
-	{"pktio poll multi",   test_odp_pktio_poll_multi},
-	{"pktio sched queues", test_odp_pktio_sched_queue},
-	{"pktio sched multi",  test_odp_pktio_sched_multi},
+	{"pktio open",		test_odp_pktio_open},
+	{"pktio close",		test_odp_pktio_close},
+	{"pktio inq",		test_odp_pktio_inq},
+	{"pktio outq",		test_odp_pktio_outq},
+	{"pktio poll queues",	test_odp_pktio_poll_queue},
+	{"pktio poll multi",	test_odp_pktio_poll_multi},
+	{"pktio sched queues",	test_odp_pktio_sched_queue},
+	{"pktio sched multi",	test_odp_pktio_sched_multi},
+	{"pktio mtu",		pktio_test_mtu},
+	{"pktio promisc mode",	pktio_test_promisc},
+	{"pktio mac",		pktio_test_mac},
 	CU_TEST_INFO_NULL
 };
 
 CU_SuiteInfo odp_testsuites[] = {
-	{"odp_pktio", init_pktio_suite, NULL, NULL, NULL, pktio_tests},
+	{"Packet I/O", init_pktio_suite, NULL, NULL, NULL, pktio_tests},
 	CU_SUITE_INFO_NULL
 };