Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 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 | |
Damjan Marion | 696f1ad | 2016-12-23 22:42:41 +0100 | [diff] [blame] | 16 | #define DPDK_NB_RX_DESC_DEFAULT 1024 |
| 17 | #define DPDK_NB_TX_DESC_DEFAULT 1024 |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 18 | #define DPDK_NB_RX_DESC_VIRTIO 256 |
| 19 | #define DPDK_NB_TX_DESC_VIRTIO 256 |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 20 | |
Damjan Marion | 1f0da17 | 2016-07-13 22:44:18 +0200 | [diff] [blame] | 21 | #define I40E_DEV_ID_SFP_XL710 0x1572 |
| 22 | #define I40E_DEV_ID_QSFP_A 0x1583 |
| 23 | #define I40E_DEV_ID_QSFP_B 0x1584 |
| 24 | #define I40E_DEV_ID_QSFP_C 0x1585 |
| 25 | #define I40E_DEV_ID_10G_BASE_T 0x1586 |
| 26 | #define I40E_DEV_ID_VF 0x154C |
Damjan Marion | 1f0da17 | 2016-07-13 22:44:18 +0200 | [diff] [blame] | 27 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 28 | /* These args appear by themselves */ |
| 29 | #define foreach_eal_double_hyphen_predicate_arg \ |
| 30 | _(no-shconf) \ |
| 31 | _(no-hpet) \ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 32 | _(no-huge) \ |
Damjan Marion | f530a55 | 2016-10-25 18:53:41 +0200 | [diff] [blame] | 33 | _(vmware-tsc-map) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 34 | |
| 35 | #define foreach_eal_single_hyphen_mandatory_arg \ |
| 36 | _(coremask, c) \ |
| 37 | _(nchannels, n) \ |
| 38 | |
| 39 | #define foreach_eal_single_hyphen_arg \ |
| 40 | _(blacklist, b) \ |
| 41 | _(mem-alloc-request, m) \ |
| 42 | _(force-ranks, r) |
| 43 | |
| 44 | /* These args are preceeded by "--" and followed by a single string */ |
| 45 | #define foreach_eal_double_hyphen_arg \ |
| 46 | _(huge-dir) \ |
| 47 | _(proc-type) \ |
| 48 | _(file-prefix) \ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 49 | _(vdev) |
| 50 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 51 | static inline void |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 52 | dpdk_get_xstats (dpdk_device_t * xd) |
| 53 | { |
| 54 | int len; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 55 | if ((len = rte_eth_xstats_get (xd->device_index, NULL, 0)) > 0) |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 56 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 57 | vec_validate (xd->xstats, len - 1); |
| 58 | vec_validate (xd->last_cleared_xstats, len - 1); |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 59 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 60 | len = |
| 61 | rte_eth_xstats_get (xd->device_index, xd->xstats, |
| 62 | vec_len (xd->xstats)); |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 63 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 64 | ASSERT (vec_len (xd->xstats) == len); |
| 65 | ASSERT (vec_len (xd->last_cleared_xstats) == len); |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 66 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 67 | _vec_len (xd->xstats) = len; |
| 68 | _vec_len (xd->last_cleared_xstats) = len; |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 69 | |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | |
| 74 | static inline void |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 75 | dpdk_update_counters (dpdk_device_t * xd, f64 now) |
| 76 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 77 | vlib_simple_counter_main_t *cm; |
| 78 | vnet_main_t *vnm = vnet_get_main (); |
| 79 | u32 my_cpu = os_get_cpu_number (); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 80 | u64 rxerrors, last_rxerrors; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 81 | |
| 82 | /* only update counters for PMD interfaces */ |
Damjan Marion | 5643170 | 2016-09-19 13:18:09 +0200 | [diff] [blame] | 83 | if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 84 | return; |
| 85 | |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 86 | xd->time_last_stats_update = now ? now : xd->time_last_stats_update; |
| 87 | clib_memcpy (&xd->last_stats, &xd->stats, sizeof (xd->last_stats)); |
| 88 | rte_eth_stats_get (xd->device_index, &xd->stats); |
| 89 | |
| 90 | /* maybe bump interface rx no buffer counter */ |
| 91 | if (PREDICT_FALSE (xd->stats.rx_nombuf != xd->last_stats.rx_nombuf)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 92 | { |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 93 | cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, |
| 94 | VNET_INTERFACE_COUNTER_RX_NO_BUF); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 95 | |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 96 | vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index, |
| 97 | xd->stats.rx_nombuf - |
| 98 | xd->last_stats.rx_nombuf); |
| 99 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 100 | |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 101 | /* missed pkt counter */ |
| 102 | if (PREDICT_FALSE (xd->stats.imissed != xd->last_stats.imissed)) |
| 103 | { |
| 104 | cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, |
| 105 | VNET_INTERFACE_COUNTER_RX_MISS); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 106 | |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 107 | vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index, |
| 108 | xd->stats.imissed - |
| 109 | xd->last_stats.imissed); |
| 110 | } |
| 111 | rxerrors = xd->stats.ierrors; |
| 112 | last_rxerrors = xd->last_stats.ierrors; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 113 | |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 114 | if (PREDICT_FALSE (rxerrors != last_rxerrors)) |
| 115 | { |
| 116 | cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, |
| 117 | VNET_INTERFACE_COUNTER_RX_ERROR); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 118 | |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 119 | vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index, |
| 120 | rxerrors - last_rxerrors); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 121 | } |
| 122 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 123 | dpdk_get_xstats (xd); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 124 | } |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 125 | |
| 126 | /* |
| 127 | * fd.io coding-style-patch-verification: ON |
| 128 | * |
| 129 | * Local Variables: |
| 130 | * eval: (c-set-style "gnu") |
| 131 | * End: |
| 132 | */ |