LCOV - code coverage report
Current view: top level - plugins/avf - avf_test.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 54 0.0 %
Date: 2023-07-05 22:20:52 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /*
       2             :  *------------------------------------------------------------------
       3             :  * Copyright (c) 2018 Cisco and/or its affiliates.
       4             :  * Licensed under the Apache License, Version 2.0 (the "License");
       5             :  * you may not use this file except in compliance with the License.
       6             :  * You may obtain a copy of the License at:
       7             :  *
       8             :  *     http://www.apache.org/licenses/LICENSE-2.0
       9             :  *
      10             :  * Unless required by applicable law or agreed to in writing, software
      11             :  * distributed under the License is distributed on an "AS IS" BASIS,
      12             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13             :  * See the License for the specific language governing permissions and
      14             :  * limitations under the License.
      15             :  *------------------------------------------------------------------
      16             :  */
      17             : 
      18             : #include <vlib/vlib.h>
      19             : #include <vlib/unix/unix.h>
      20             : #include <vlib/pci/pci.h>
      21             : #include <vnet/ethernet/ethernet.h>
      22             : 
      23             : #include <vat/vat.h>
      24             : #include <vlibapi/api.h>
      25             : #include <vlibmemory/api.h>
      26             : 
      27             : #include <vppinfra/error.h>
      28             : #include <avf/avf.h>
      29             : 
      30             : #define __plugin_msg_base avf_test_main.msg_id_base
      31             : #include <vlibapi/vat_helper_macros.h>
      32             : 
      33             : /* declare message IDs */
      34             : #include <avf/avf.api_enum.h>
      35             : #include <avf/avf.api_types.h>
      36             : 
      37             : typedef struct
      38             : {
      39             :   /* API message ID base */
      40             :   u16 msg_id_base;
      41             :   vat_main_t *vat_main;
      42             : } avf_test_main_t;
      43             : 
      44             : avf_test_main_t avf_test_main;
      45             : 
      46             : /* avf create API */
      47             : static int
      48           0 : api_avf_create (vat_main_t * vam)
      49             : {
      50           0 :   unformat_input_t *i = vam->input;
      51             :   vl_api_avf_create_t *mp;
      52             :   avf_create_if_args_t args;
      53             :   uint32_t tmp;
      54             :   int ret;
      55             :   u32 x[4];
      56             : 
      57           0 :   clib_memset (&args, 0, sizeof (avf_create_if_args_t));
      58             : 
      59           0 :   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
      60             :     {
      61           0 :       if (unformat (i, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
      62             :         {
      63           0 :           args.addr.domain = x[0];
      64           0 :           args.addr.bus = x[1];
      65           0 :           args.addr.slot = x[2];
      66           0 :           args.addr.function = x[3];
      67             :         }
      68           0 :       else if (unformat (i, "elog"))
      69           0 :         args.enable_elog = 1;
      70           0 :       else if (unformat (i, "rx-queue-size %u", &tmp))
      71           0 :         args.rxq_size = tmp;
      72           0 :       else if (unformat (i, "tx-queue-size %u", &tmp))
      73           0 :         args.txq_size = tmp;
      74           0 :       else if (unformat (i, "num-rx-queues %u", &tmp))
      75           0 :         args.rxq_num = tmp;
      76             :       else
      77             :         {
      78           0 :           clib_warning ("unknown input '%U'", format_unformat_error, i);
      79           0 :           return -99;
      80             :         }
      81             :     }
      82             : 
      83           0 :   M (AVF_CREATE, mp);
      84             : 
      85           0 :   mp->pci_addr = clib_host_to_net_u32 (args.addr.as_u32);
      86           0 :   mp->enable_elog = clib_host_to_net_u16 (args.enable_elog);
      87           0 :   mp->rxq_num = clib_host_to_net_u16 (args.rxq_num);
      88           0 :   mp->rxq_size = clib_host_to_net_u16 (args.rxq_size);
      89           0 :   mp->txq_size = clib_host_to_net_u16 (args.txq_size);
      90             : 
      91           0 :   S (mp);
      92           0 :   W (ret);
      93             : 
      94           0 :   return ret;
      95             : }
      96             : 
      97             : /* avf-create reply handler */
      98             : static void
      99           0 : vl_api_avf_create_reply_t_handler (vl_api_avf_create_reply_t * mp)
     100             : {
     101           0 :   vat_main_t *vam = avf_test_main.vat_main;
     102           0 :   i32 retval = ntohl (mp->retval);
     103             : 
     104           0 :   if (retval == 0)
     105             :     {
     106           0 :       fformat (vam->ofp, "created avf with sw_if_index %d\n",
     107             :                ntohl (mp->sw_if_index));
     108             :     }
     109             : 
     110           0 :   vam->retval = retval;
     111           0 :   vam->result_ready = 1;
     112           0 :   vam->regenerate_interface_table = 1;
     113           0 : }
     114             : 
     115             : /* avf delete API */
     116             : static int
     117           0 : api_avf_delete (vat_main_t * vam)
     118             : {
     119           0 :   unformat_input_t *i = vam->input;
     120             :   vl_api_avf_delete_t *mp;
     121           0 :   u32 sw_if_index = 0;
     122           0 :   u8 index_defined = 0;
     123             :   int ret;
     124             : 
     125           0 :   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
     126             :     {
     127           0 :       if (unformat (i, "sw_if_index %u", &sw_if_index))
     128           0 :         index_defined = 1;
     129             :       else
     130             :         {
     131           0 :           clib_warning ("unknown input '%U'", format_unformat_error, i);
     132           0 :           return -99;
     133             :         }
     134             :     }
     135             : 
     136           0 :   if (!index_defined)
     137             :     {
     138           0 :       errmsg ("missing sw_if_index\n");
     139           0 :       return -99;
     140             :     }
     141             : 
     142           0 :   M (AVF_DELETE, mp);
     143             : 
     144           0 :   mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
     145             : 
     146           0 :   S (mp);
     147           0 :   W (ret);
     148             : 
     149           0 :   return ret;
     150             : }
     151             : 
     152             : #include <avf/avf.api_test.c>
     153             : 
     154             : /*
     155             :  * fd.io coding-style-patch-verification: ON
     156             :  *
     157             :  * Local Variables:
     158             :  * eval: (c-set-style "gnu")
     159             :  * End:
     160             :  */

Generated by: LCOV version 1.14