LCOV - code coverage report
Current view: top level - vnet/devices/virtio - virtio_pci_modern.h (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 8 0.0 %
Date: 2023-07-05 22:20:52 Functions: 0 8 0.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2020 Cisco and/or its affiliates.
       3             :  * Licensed under the Apache License, Version 2.0 (the "License");
       4             :  * you may not use this file except in compliance with the License.
       5             :  * You may obtain a copy of the License at:
       6             :  *
       7             :  *     http://www.apache.org/licenses/LICENSE-2.0
       8             :  *
       9             :  * Unless required by applicable law or agreed to in writing, software
      10             :  * distributed under the License is distributed on an "AS IS" BASIS,
      11             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             :  * See the License for the specific language governing permissions and
      13             :  * limitations under the License.
      14             :  */
      15             : 
      16             : #include <vnet/devices/virtio/virtio.h>
      17             : #include <vnet/devices/virtio/pci.h>
      18             : 
      19             : /* common configuration */
      20             : #define VIRTIO_FEATURE_SELECT_HI 1
      21             : #define VIRTIO_FEATURE_SELECT_LO 0
      22             : 
      23             : #define VIRTIO_DEVICE_FEATURE_SELECT_OFFSET(v)                    \
      24             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      25             :                                          device_feature_select))
      26             : #define VIRTIO_DEVICE_FEATURE_OFFSET(v)                           \
      27             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      28             :                                                 device_feature))
      29             : #define VIRTIO_DRIVER_FEATURE_SELECT_OFFSET(v)                    \
      30             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      31             :                                          driver_feature_select))
      32             : #define VIRTIO_DRIVER_FEATURE_OFFSET(v)                           \
      33             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      34             :                                                 driver_feature))
      35             : #define VIRTIO_MSIX_CONFIG_VECTOR_OFFSET(v)                       \
      36             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      37             :                                                    msix_config))
      38             : #define VIRTIO_NUM_QUEUES_OFFSET(v)                               \
      39             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      40             :                                                     num_queues))
      41             : #define VIRTIO_DEVICE_STATUS_OFFSET(v)                            \
      42             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      43             :                                                  device_status))
      44             : #define VIRTIO_CONFIG_GENERATION_OFFSET(v)                        \
      45             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      46             :                                              config_generation))
      47             : #define VIRTIO_QUEUE_SELECT_OFFSET(v)                             \
      48             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      49             :                                                   queue_select))
      50             : #define VIRTIO_QUEUE_SIZE_OFFSET(v)                               \
      51             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      52             :                                                     queue_size))
      53             : #define VIRTIO_QUEUE_MSIX_VECTOR_OFFSET(v)                        \
      54             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      55             :                                              queue_msix_vector))
      56             : #define VIRTIO_QUEUE_ENABLE_OFFSET(v)                             \
      57             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      58             :                                                   queue_enable))
      59             : #define VIRTIO_QUEUE_NOTIFY_OFF_OFFSET(v)                         \
      60             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      61             :                                               queue_notify_off))
      62             : #define VIRTIO_QUEUE_DESC_OFFSET(v)                               \
      63             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      64             :                                                     queue_desc))
      65             : #define VIRTIO_QUEUE_DRIVER_OFFSET(v)                             \
      66             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      67             :                                                   queue_driver))
      68             : #define VIRTIO_QUEUE_DEVICE_OFFSET(v)                             \
      69             :    (v->common_offset + STRUCT_OFFSET_OF (virtio_pci_common_cfg_t, \
      70             :                                                   queue_device))
      71             : /* device configuration */
      72             : #define VIRTIO_MAC_OFFSET(v)                                      \
      73             :    (v->device_offset + STRUCT_OFFSET_OF (virtio_net_config_t,     \
      74             :                                                            mac))
      75             : #define VIRTIO_STATUS_OFFSET(v)                                   \
      76             :    (v->device_offset + STRUCT_OFFSET_OF (virtio_net_config_t,     \
      77             :                                                         status))
      78             : #define VIRTIO_MAX_VIRTQUEUE_PAIRS_OFFSET(v)                      \
      79             :    (v->device_offset + STRUCT_OFFSET_OF (virtio_net_config_t,     \
      80             :                                            max_virtqueue_pairs))
      81             : #define VIRTIO_MTU_OFFSET(v)                                      \
      82             :    (v->device_offset + STRUCT_OFFSET_OF (virtio_net_config_t,     \
      83             :                                                            mtu))
      84             : /* interrupt service routine */
      85             : #define VIRTIO_ISR_OFFSET(v) (v->isr_offset)
      86             : /* notification */
      87             : #define VIRTIO_NOTIFICATION_OFFSET(v) (v->notify_offset)
      88             : 
      89             : #define _(t)                                                         \
      90             : static_always_inline t                                               \
      91             : virtio_pci_reg_read_##t (virtio_if_t * vif, u32 offset)              \
      92             : {                                                                    \
      93             :   t val;                                                             \
      94             :   val = *(volatile t *) (vif->bar + offset);                      \
      95             :   return val;                                                        \
      96             : }
      97             : 
      98           0 : _(u64);
      99           0 : _(u32);
     100           0 : _(u16);
     101           0 : _(u8);
     102             : 
     103             : #undef _
     104             : 
     105             : #define _(t)                                                         \
     106             : static_always_inline void                                            \
     107             : virtio_pci_reg_write_##t (virtio_if_t * vif, u32 offset, t val)      \
     108             : {                                                                    \
     109             :   *(volatile t *) ((u8 *) vif->bar + offset) = val;               \
     110             : }
     111             : 
     112           0 : _(u64);
     113           0 : _(u32);
     114           0 : _(u16);
     115           0 : _(u8);
     116             : 
     117             : #undef _
     118             : 
     119             : /*
     120             :  * fd.io coding-style-patch-verification: ON
     121             :  *
     122             :  * Local Variables:
     123             :  * eval: (c-set-style "gnu")
     124             :  * End:
     125             :  */

Generated by: LCOV version 1.14