1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(C) 2021 Marvell. 3 */ 4 5 #include <ctype.h> 6 #include "cnxk_telemetry.h" 7 #include "roc_api.h" 8 #include "roc_priv.h" 9 10 struct nix_tel_node { 11 TAILQ_ENTRY(nix_tel_node) node; 12 struct roc_nix *nix; 13 uint16_t n_rq; 14 uint16_t n_cq; 15 uint16_t n_sq; 16 struct roc_nix_rq **rqs; 17 struct roc_nix_cq **cqs; 18 struct roc_nix_sq **sqs; 19 }; 20 21 TAILQ_HEAD(nix_tel_node_list, nix_tel_node); 22 static struct nix_tel_node_list nix_list; 23 24 static struct nix_tel_node * 25 nix_tel_node_get(struct roc_nix *roc_nix) 26 { 27 struct nix_tel_node *node, *roc_node = NULL; 28 29 TAILQ_FOREACH(node, &nix_list, node) { 30 if (node->nix == roc_nix) { 31 roc_node = node; 32 break; 33 } 34 } 35 36 return roc_node; 37 } 38 39 int 40 nix_tel_node_add(struct roc_nix *roc_nix) 41 { 42 struct nix *nix = roc_nix_to_nix_priv(roc_nix); 43 struct nix_tel_node *node; 44 45 node = nix_tel_node_get(roc_nix); 46 if (node) { 47 if (nix->nb_rx_queues == node->n_rq && 48 nix->nb_tx_queues == node->n_sq) 49 return 0; 50 51 nix_tel_node_del(roc_nix); 52 } 53 54 node = plt_zmalloc(sizeof(struct nix_tel_node), 0); 55 if (!node) 56 return -1; 57 58 node->nix = roc_nix; 59 node->rqs = 60 plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_rq *), 0); 61 node->cqs = 62 plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_cq *), 0); 63 node->sqs = 64 plt_zmalloc(nix->nb_tx_queues * sizeof(struct roc_nix_sq *), 0); 65 TAILQ_INSERT_TAIL(&nix_list, node, node); 66 67 return 0; 68 } 69 70 void 71 nix_tel_node_del(struct roc_nix *roc_nix) 72 { 73 struct nix_tel_node *node; 74 75 TAILQ_FOREACH(node, &nix_list, node) { 76 if (node->nix == roc_nix) { 77 plt_free(node->rqs); 78 plt_free(node->cqs); 79 plt_free(node->sqs); 80 TAILQ_REMOVE(&nix_list, node, node); 81 } 82 } 83 84 plt_free(node); 85 } 86 87 static struct nix_tel_node * 88 nix_tel_node_get_by_pcidev_name(const char *name) 89 { 90 struct nix_tel_node *node, *roc_node = NULL; 91 92 TAILQ_FOREACH(node, &nix_list, node) { 93 if (!strncmp(node->nix->pci_dev->name, name, 94 PCI_PRI_STR_SIZE)) { 95 roc_node = node; 96 break; 97 } 98 } 99 100 return roc_node; 101 } 102 103 int 104 nix_tel_node_add_rq(struct roc_nix_rq *rq) 105 { 106 struct nix_tel_node *node; 107 108 node = nix_tel_node_get(rq->roc_nix); 109 if (!node) 110 return -1; 111 112 node->rqs[rq->qid] = rq; 113 node->n_rq++; 114 return 0; 115 } 116 117 int 118 nix_tel_node_add_cq(struct roc_nix_cq *cq) 119 { 120 struct nix_tel_node *node; 121 122 node = nix_tel_node_get(cq->roc_nix); 123 if (!node) 124 return -1; 125 126 node->cqs[cq->qid] = cq; 127 node->n_cq++; 128 return 0; 129 } 130 131 int 132 nix_tel_node_add_sq(struct roc_nix_sq *sq) 133 { 134 struct nix_tel_node *node; 135 136 node = nix_tel_node_get(sq->roc_nix); 137 if (!node) 138 return -1; 139 140 node->sqs[sq->qid] = sq; 141 node->n_sq++; 142 return 0; 143 } 144 145 static int 146 cnxk_tel_nix(struct roc_nix *roc_nix, struct plt_tel_data *d) 147 { 148 struct nix *nix = roc_nix_to_nix_priv(roc_nix); 149 150 struct dev *dev = &nix->dev; 151 152 plt_tel_data_add_dict_ptr(d, "nix", nix); 153 plt_tel_data_add_dict_int(d, "pf_func", dev->pf_func); 154 plt_tel_data_add_dict_int(d, "pf", dev_get_pf(dev->pf_func)); 155 plt_tel_data_add_dict_int(d, "vf", dev_get_vf(dev->pf_func)); 156 157 CNXK_TEL_DICT_PTR(d, dev, bar2); 158 CNXK_TEL_DICT_PTR(d, dev, bar4); 159 CNXK_TEL_DICT_INT(d, roc_nix, port_id); 160 CNXK_TEL_DICT_INT(d, roc_nix, rss_tag_as_xor); 161 CNXK_TEL_DICT_INT(d, roc_nix, max_sqb_count); 162 CNXK_TEL_DICT_PTR(d, nix, pci_dev); 163 CNXK_TEL_DICT_PTR(d, nix, base); 164 CNXK_TEL_DICT_PTR(d, nix, lmt_base); 165 CNXK_TEL_DICT_INT(d, nix, reta_sz); 166 CNXK_TEL_DICT_INT(d, nix, tx_chan_base); 167 CNXK_TEL_DICT_INT(d, nix, rx_chan_base); 168 CNXK_TEL_DICT_INT(d, nix, nb_tx_queues); 169 CNXK_TEL_DICT_INT(d, nix, nb_rx_queues); 170 CNXK_TEL_DICT_INT(d, nix, lso_tsov6_idx); 171 CNXK_TEL_DICT_INT(d, nix, lso_tsov4_idx); 172 173 plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v4", 174 nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V4]); 175 plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v6", 176 nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V6]); 177 plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v4", 178 nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V4]); 179 plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v6", 180 nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V6]); 181 plt_tel_data_add_dict_int(d, "lso_tun_v4v4", 182 nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V4]); 183 plt_tel_data_add_dict_int(d, "lso_tun_v4v6", 184 nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V6]); 185 plt_tel_data_add_dict_int(d, "lso_tun_v6v4", 186 nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V4]); 187 plt_tel_data_add_dict_int(d, "lso_tun_v6v6", 188 nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V6]); 189 190 CNXK_TEL_DICT_INT(d, nix, lf_tx_stats); 191 CNXK_TEL_DICT_INT(d, nix, lf_rx_stats); 192 CNXK_TEL_DICT_INT(d, nix, cgx_links); 193 CNXK_TEL_DICT_INT(d, nix, lbk_links); 194 CNXK_TEL_DICT_INT(d, nix, sdp_links); 195 CNXK_TEL_DICT_INT(d, nix, tx_link); 196 CNXK_TEL_DICT_INT(d, nix, sqb_size); 197 CNXK_TEL_DICT_INT(d, nix, msixoff); 198 CNXK_TEL_DICT_INT(d, nix, cints); 199 CNXK_TEL_DICT_INT(d, nix, qints); 200 CNXK_TEL_DICT_INT(d, nix, sdp_link); 201 CNXK_TEL_DICT_INT(d, nix, ptp_en); 202 CNXK_TEL_DICT_INT(d, nix, rss_alg_idx); 203 CNXK_TEL_DICT_INT(d, nix, tx_pause); 204 205 return 0; 206 } 207 208 static int 209 cnxk_tel_nix_rq(struct roc_nix_rq *rq, struct plt_tel_data *d) 210 { 211 plt_tel_data_add_dict_ptr(d, "nix_rq", rq); 212 CNXK_TEL_DICT_INT(d, rq, qid); 213 CNXK_TEL_DICT_PTR(d, rq, aura_handle); 214 CNXK_TEL_DICT_INT(d, rq, ipsech_ena); 215 CNXK_TEL_DICT_INT(d, rq, first_skip); 216 CNXK_TEL_DICT_INT(d, rq, later_skip); 217 CNXK_TEL_DICT_INT(d, rq, lpb_size); 218 CNXK_TEL_DICT_INT(d, rq, sso_ena); 219 CNXK_TEL_DICT_INT(d, rq, tag_mask); 220 CNXK_TEL_DICT_INT(d, rq, flow_tag_width); 221 CNXK_TEL_DICT_INT(d, rq, tt); 222 CNXK_TEL_DICT_INT(d, rq, hwgrp); 223 CNXK_TEL_DICT_INT(d, rq, vwqe_ena); 224 CNXK_TEL_DICT_INT(d, rq, vwqe_first_skip); 225 CNXK_TEL_DICT_INT(d, rq, vwqe_max_sz_exp); 226 CNXK_TEL_DICT_INT(d, rq, vwqe_wait_tmo); 227 CNXK_TEL_DICT_INT(d, rq, vwqe_aura_handle); 228 CNXK_TEL_DICT_PTR(d, rq, roc_nix); 229 230 return 0; 231 } 232 233 static int 234 cnxk_tel_nix_cq(struct roc_nix_cq *cq, struct plt_tel_data *d) 235 { 236 plt_tel_data_add_dict_ptr(d, "nix_cq", cq); 237 CNXK_TEL_DICT_INT(d, cq, qid); 238 CNXK_TEL_DICT_INT(d, cq, nb_desc); 239 CNXK_TEL_DICT_PTR(d, cq, roc_nix); 240 CNXK_TEL_DICT_PTR(d, cq, door); 241 CNXK_TEL_DICT_PTR(d, cq, status); 242 CNXK_TEL_DICT_PTR(d, cq, wdata); 243 CNXK_TEL_DICT_PTR(d, cq, desc_base); 244 CNXK_TEL_DICT_INT(d, cq, qmask); 245 246 return 0; 247 } 248 249 static int 250 cnxk_tel_nix_sq(struct roc_nix_sq *sq, struct plt_tel_data *d) 251 { 252 plt_tel_data_add_dict_ptr(d, "nix_sq", sq); 253 CNXK_TEL_DICT_INT(d, sq, qid); 254 CNXK_TEL_DICT_INT(d, sq, max_sqe_sz); 255 CNXK_TEL_DICT_INT(d, sq, nb_desc); 256 CNXK_TEL_DICT_INT(d, sq, sqes_per_sqb_log2); 257 CNXK_TEL_DICT_PTR(d, sq, roc_nix); 258 CNXK_TEL_DICT_PTR(d, sq, aura_handle); 259 CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs_adj); 260 CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs); 261 CNXK_TEL_DICT_PTR(d, sq, io_addr); 262 CNXK_TEL_DICT_PTR(d, sq, lmt_addr); 263 CNXK_TEL_DICT_PTR(d, sq, sqe_mem); 264 CNXK_TEL_DICT_PTR(d, sq, fc); 265 266 return 0; 267 } 268 269 static void 270 nix_rq_ctx_cn9k(volatile void *qctx, struct plt_tel_data *d) 271 { 272 volatile struct nix_rq_ctx_s *ctx; 273 274 ctx = (volatile struct nix_rq_ctx_s *)qctx; 275 276 /* W0 */ 277 CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_); 278 CNXK_TEL_DICT_BF_PTR(d, ctx, substream, w0_); 279 CNXK_TEL_DICT_INT(d, ctx, cq, w0_); 280 CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0_); 281 CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0_); 282 CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0_); 283 CNXK_TEL_DICT_INT(d, ctx, ena, w0_); 284 285 /* W1 */ 286 CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_); 287 CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_); 288 CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_); 289 CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_); 290 CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_); 291 CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_); 292 CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_); 293 CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_); 294 CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_); 295 296 /* W2 */ 297 CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_); 298 CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_); 299 CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_); 300 CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_); 301 CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_); 302 CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_); 303 CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_); 304 CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_); 305 CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_); 306 307 /* W3 */ 308 CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_); 309 CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_); 310 CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_); 311 CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_); 312 CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_); 313 CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_); 314 CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_); 315 CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_); 316 317 /* W4 */ 318 CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_); 319 CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_); 320 CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_); 321 CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_); 322 CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_); 323 CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_); 324 CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_); 325 326 /* W5 */ 327 CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_); 328 CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_); 329 CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_); 330 CNXK_TEL_DICT_INT(d, ctx, ltag, w5_); 331 332 /* W6 */ 333 CNXK_TEL_DICT_U64(d, ctx, octs, w6_); 334 335 /* W7 */ 336 CNXK_TEL_DICT_U64(d, ctx, pkts, w7_); 337 338 /* W8 */ 339 CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_); 340 341 /* W9 */ 342 CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_); 343 344 /* W10 */ 345 CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_); 346 } 347 348 static void 349 nix_rq_ctx_cn10k(volatile void *qctx, struct plt_tel_data *d) 350 { 351 volatile struct nix_cn10k_rq_ctx_s *ctx; 352 353 ctx = (volatile struct nix_cn10k_rq_ctx_s *)qctx; 354 355 /* W0 */ 356 CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_); 357 CNXK_TEL_DICT_INT(d, ctx, len_ol3_dis, w0_); 358 CNXK_TEL_DICT_INT(d, ctx, len_ol4_dis, w0_); 359 CNXK_TEL_DICT_INT(d, ctx, len_il3_dis, w0_); 360 CNXK_TEL_DICT_INT(d, ctx, len_il4_dis, w0_); 361 CNXK_TEL_DICT_INT(d, ctx, csum_ol4_dis, w0_); 362 CNXK_TEL_DICT_INT(d, ctx, lenerr_dis, w0_); 363 CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0); 364 CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0); 365 CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0); 366 CNXK_TEL_DICT_INT(d, ctx, ena, w0); 367 368 /* W1 */ 369 CNXK_TEL_DICT_INT(d, ctx, chi_ena, w1_); 370 CNXK_TEL_DICT_INT(d, ctx, ipsecd_drop_en, w1_); 371 CNXK_TEL_DICT_INT(d, ctx, pb_stashing, w1_); 372 CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_); 373 CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_); 374 CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_); 375 CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_); 376 CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_); 377 CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_); 378 CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_); 379 CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_); 380 CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_); 381 382 /* W2 */ 383 CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_); 384 CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_); 385 CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_); 386 CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_); 387 CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_); 388 CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_); 389 CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_); 390 CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_); 391 CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_); 392 CNXK_TEL_DICT_INT(d, ctx, policer_ena, w2_); 393 CNXK_TEL_DICT_INT(d, ctx, band_prof_id, w2_); 394 395 /* W3 */ 396 CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_); 397 CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_); 398 CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_); 399 CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_); 400 CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_); 401 CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_); 402 CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_); 403 CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_); 404 405 /* W4 */ 406 CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_); 407 CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_); 408 CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_); 409 CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_); 410 CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_); 411 CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_); 412 CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_); 413 414 /* W5 */ 415 CNXK_TEL_DICT_INT(d, ctx, vwqe_skip, w5_); 416 CNXK_TEL_DICT_INT(d, ctx, max_vsize_exp, w5_); 417 CNXK_TEL_DICT_INT(d, ctx, vtime_wait, w5_); 418 CNXK_TEL_DICT_INT(d, ctx, vwqe_ena, w5_); 419 CNXK_TEL_DICT_INT(d, ctx, ipsec_vwqe, w5_); 420 CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_); 421 CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_); 422 CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_); 423 CNXK_TEL_DICT_INT(d, ctx, ltag, w5_); 424 425 /* W6 */ 426 CNXK_TEL_DICT_U64(d, ctx, octs, w6_); 427 428 /* W7 */ 429 CNXK_TEL_DICT_U64(d, ctx, pkts, w7_); 430 431 /* W8 */ 432 CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_); 433 434 /* W9 */ 435 CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_); 436 437 /* W10 */ 438 CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_); 439 } 440 441 static void 442 nix_rq_ctx(volatile void *qctx, struct plt_tel_data *d) 443 { 444 volatile struct nix_cn20k_rq_ctx_s *ctx; 445 446 ctx = (volatile struct nix_cn20k_rq_ctx_s *)qctx; 447 448 /* W0 */ 449 CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_); 450 CNXK_TEL_DICT_INT(d, ctx, len_ol3_dis, w0_); 451 CNXK_TEL_DICT_INT(d, ctx, len_ol4_dis, w0_); 452 CNXK_TEL_DICT_INT(d, ctx, len_il3_dis, w0_); 453 CNXK_TEL_DICT_INT(d, ctx, len_il4_dis, w0_); 454 CNXK_TEL_DICT_INT(d, ctx, csum_ol4_dis, w0_); 455 CNXK_TEL_DICT_INT(d, ctx, csum_il4_dis, w0_); 456 CNXK_TEL_DICT_INT(d, ctx, lenerr_dis, w0_); 457 CNXK_TEL_DICT_INT(d, ctx, port_ol4_dis, w0_); 458 CNXK_TEL_DICT_INT(d, ctx, port_il4_dis, w0_); 459 CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0); 460 CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0); 461 CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0); 462 CNXK_TEL_DICT_INT(d, ctx, ena, w0); 463 464 /* W1 */ 465 CNXK_TEL_DICT_INT(d, ctx, chi_ena, w1_); 466 CNXK_TEL_DICT_INT(d, ctx, ipsecd_drop_en, w1_); 467 CNXK_TEL_DICT_INT(d, ctx, pb_stashing, w1_); 468 CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_); 469 CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_); 470 CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_); 471 CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_); 472 CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_); 473 CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_); 474 CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_); 475 CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_); 476 CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_); 477 478 /* W2 */ 479 CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_); 480 CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_); 481 CNXK_TEL_DICT_INT(d, ctx, band_prof_id_h, w2_); 482 CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_); 483 CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_); 484 CNXK_TEL_DICT_INT(d, ctx, sso_bp_ena, w2_); 485 CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_); 486 CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_); 487 CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_); 488 CNXK_TEL_DICT_INT(d, ctx, spb_high_sizem1, w2_); 489 CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_); 490 CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_); 491 CNXK_TEL_DICT_INT(d, ctx, policer_ena, w2_); 492 CNXK_TEL_DICT_INT(d, ctx, band_prof_id_l, w2_); 493 494 /* W3 */ 495 CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_); 496 CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_); 497 CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_); 498 CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_); 499 CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_); 500 CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_); 501 CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_); 502 CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_); 503 504 /* W4 */ 505 CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_); 506 CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_); 507 CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_); 508 CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_); 509 CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_); 510 CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_); 511 CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_); 512 513 /* W5 */ 514 CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_); 515 CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_); 516 CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_); 517 CNXK_TEL_DICT_INT(d, ctx, ltag, w5_); 518 519 /* W6 */ 520 CNXK_TEL_DICT_U64(d, ctx, octs, w6_); 521 522 /* W7 */ 523 CNXK_TEL_DICT_U64(d, ctx, pkts, w7_); 524 525 /* W8 */ 526 CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_); 527 528 /* W9 */ 529 CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_); 530 531 /* W10 */ 532 CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_); 533 } 534 535 static int 536 cnxk_tel_nix_rq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d) 537 { 538 struct nix *nix = roc_nix_to_nix_priv(roc_nix); 539 struct dev *dev = &nix->dev; 540 struct npa_lf *npa_lf; 541 volatile void *qctx; 542 int rc = -1; 543 544 npa_lf = idev_npa_obj_get(); 545 if (npa_lf == NULL) 546 return NPA_ERR_DEVICE_NOT_BOUNDED; 547 548 rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_RQ, n, &qctx); 549 if (rc) { 550 plt_err("Failed to get rq context"); 551 return rc; 552 } 553 554 if (roc_model_is_cn9k()) 555 nix_rq_ctx_cn9k(qctx, d); 556 else if (roc_model_is_cn10k()) 557 nix_rq_ctx_cn10k(qctx, d); 558 else 559 nix_rq_ctx(qctx, d); 560 561 return 0; 562 } 563 564 static int 565 cnxk_tel_nix_cq_ctx_cn20k(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d) 566 { 567 struct nix *nix = roc_nix_to_nix_priv(roc_nix); 568 struct dev *dev = &nix->dev; 569 struct npa_lf *npa_lf; 570 volatile struct nix_cn20k_cq_ctx_s *ctx; 571 int rc = -1; 572 573 npa_lf = idev_npa_obj_get(); 574 if (npa_lf == NULL) 575 return NPA_ERR_DEVICE_NOT_BOUNDED; 576 577 rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_CQ, n, (void *)&ctx); 578 if (rc) { 579 plt_err("Failed to get cq context"); 580 return rc; 581 } 582 583 /* W0 */ 584 CNXK_TEL_DICT_PTR(d, ctx, base, w0_); 585 586 /* W1 */ 587 CNXK_TEL_DICT_U64(d, ctx, wrptr, w1_); 588 CNXK_TEL_DICT_INT(d, ctx, avg_con, w1_); 589 CNXK_TEL_DICT_INT(d, ctx, cint_idx, w1_); 590 CNXK_TEL_DICT_INT(d, ctx, cq_err, w1_); 591 CNXK_TEL_DICT_INT(d, ctx, qint_idx, w1_); 592 CNXK_TEL_DICT_INT(d, ctx, lbpid_high, w1_); 593 CNXK_TEL_DICT_INT(d, ctx, bpid, w1_); 594 CNXK_TEL_DICT_INT(d, ctx, lbpid_med, w1_); 595 CNXK_TEL_DICT_INT(d, ctx, bp_ena, w1_); 596 CNXK_TEL_DICT_INT(d, ctx, lbpid_low, w1_); 597 CNXK_TEL_DICT_INT(d, ctx, lbp_ena, w1_); 598 599 /* W2 */ 600 CNXK_TEL_DICT_INT(d, ctx, update_time, w2_); 601 CNXK_TEL_DICT_INT(d, ctx, avg_level, w2_); 602 CNXK_TEL_DICT_INT(d, ctx, head, w2_); 603 CNXK_TEL_DICT_INT(d, ctx, tail, w2_); 604 605 /* W3 */ 606 CNXK_TEL_DICT_INT(d, ctx, cq_err_int_ena, w3_); 607 CNXK_TEL_DICT_INT(d, ctx, cq_err_int, w3_); 608 CNXK_TEL_DICT_INT(d, ctx, qsize, w3_); 609 CNXK_TEL_DICT_INT(d, ctx, stashing, w3_); 610 CNXK_TEL_DICT_INT(d, ctx, caching, w3_); 611 CNXK_TEL_DICT_INT(d, ctx, lbp_frac, w3_); 612 CNXK_TEL_DICT_INT(d, ctx, stash_thresh, w3_); 613 CNXK_TEL_DICT_INT(d, ctx, msh_valid, w3_); 614 CNXK_TEL_DICT_INT(d, ctx, msh_dst, w3_); 615 CNXK_TEL_DICT_INT(d, ctx, cpt_drop_err_en, w3_); 616 CNXK_TEL_DICT_INT(d, ctx, ena, w3_); 617 CNXK_TEL_DICT_INT(d, ctx, drop_ena, w3_); 618 CNXK_TEL_DICT_INT(d, ctx, drop, w3_); 619 CNXK_TEL_DICT_INT(d, ctx, bp, w3_); 620 621 CNXK_TEL_DICT_INT(d, ctx, lbpid_ext, w4_); 622 CNXK_TEL_DICT_INT(d, ctx, bpid_ext, w4_); 623 624 return 0; 625 } 626 627 static int 628 cnxk_tel_nix_cq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d) 629 { 630 struct nix *nix = roc_nix_to_nix_priv(roc_nix); 631 struct dev *dev = &nix->dev; 632 struct npa_lf *npa_lf; 633 volatile struct nix_cq_ctx_s *ctx; 634 int rc = -1; 635 636 if (roc_model_is_cn20k()) 637 return cnxk_tel_nix_cq_ctx_cn20k(roc_nix, n, d); 638 639 npa_lf = idev_npa_obj_get(); 640 if (npa_lf == NULL) 641 return NPA_ERR_DEVICE_NOT_BOUNDED; 642 643 rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_CQ, n, (void *)&ctx); 644 if (rc) { 645 plt_err("Failed to get cq context"); 646 return rc; 647 } 648 649 /* W0 */ 650 CNXK_TEL_DICT_PTR(d, ctx, base, w0_); 651 652 /* W1 */ 653 CNXK_TEL_DICT_U64(d, ctx, wrptr, w1_); 654 CNXK_TEL_DICT_INT(d, ctx, avg_con, w1_); 655 CNXK_TEL_DICT_INT(d, ctx, cint_idx, w1_); 656 CNXK_TEL_DICT_INT(d, ctx, cq_err, w1_); 657 CNXK_TEL_DICT_INT(d, ctx, qint_idx, w1_); 658 CNXK_TEL_DICT_INT(d, ctx, bpid, w1_); 659 CNXK_TEL_DICT_INT(d, ctx, bp_ena, w1_); 660 661 /* W2 */ 662 CNXK_TEL_DICT_INT(d, ctx, update_time, w2_); 663 CNXK_TEL_DICT_INT(d, ctx, avg_level, w2_); 664 CNXK_TEL_DICT_INT(d, ctx, head, w2_); 665 CNXK_TEL_DICT_INT(d, ctx, tail, w2_); 666 667 /* W3 */ 668 CNXK_TEL_DICT_INT(d, ctx, cq_err_int_ena, w3_); 669 CNXK_TEL_DICT_INT(d, ctx, cq_err_int, w3_); 670 CNXK_TEL_DICT_INT(d, ctx, qsize, w3_); 671 CNXK_TEL_DICT_INT(d, ctx, caching, w3_); 672 CNXK_TEL_DICT_INT(d, ctx, substream, w3_); 673 CNXK_TEL_DICT_INT(d, ctx, ena, w3_); 674 CNXK_TEL_DICT_INT(d, ctx, drop_ena, w3_); 675 CNXK_TEL_DICT_INT(d, ctx, drop, w3_); 676 CNXK_TEL_DICT_INT(d, ctx, bp, w3_); 677 678 return 0; 679 } 680 681 static void 682 nix_sq_ctx_cn9k(volatile void *qctx, struct plt_tel_data *d) 683 { 684 volatile struct nix_sq_ctx_s *ctx; 685 686 ctx = (volatile struct nix_sq_ctx_s *)qctx; 687 688 /* W0 */ 689 CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_); 690 CNXK_TEL_DICT_INT(d, ctx, cq, w0_); 691 CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_); 692 CNXK_TEL_DICT_INT(d, ctx, substream, w0_); 693 CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_); 694 CNXK_TEL_DICT_INT(d, ctx, ena, w0_); 695 696 /* W1 */ 697 CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_); 698 CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_); 699 CNXK_TEL_DICT_INT(d, ctx, smq_rr_quantum, w1_); 700 CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_); 701 CNXK_TEL_DICT_INT(d, ctx, xoff, w1_); 702 CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_); 703 CNXK_TEL_DICT_INT(d, ctx, smq, w1_); 704 705 /* W2 */ 706 CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_); 707 CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_); 708 CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_); 709 CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_); 710 CNXK_TEL_DICT_INT(d, ctx, smq_rr_count, w2_); 711 712 /* W3 */ 713 CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_); 714 CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_); 715 CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_); 716 CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_); 717 CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_); 718 CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_); 719 CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_); 720 CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_); 721 CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_); 722 CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_); 723 CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_); 724 CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_); 725 726 /* W4 */ 727 CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_); 728 729 /* W5 */ 730 CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_); 731 732 /* W6 */ 733 CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_); 734 735 /* W7 */ 736 CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_); 737 738 /* W8 */ 739 CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_); 740 741 /* W9 */ 742 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_); 743 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_); 744 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_); 745 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_); 746 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_); 747 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_); 748 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_); 749 750 /* W10 */ 751 CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_); 752 753 /* W11 */ 754 CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_); 755 756 /* W12 */ 757 CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_); 758 759 /* W14 */ 760 CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_); 761 762 /* W15 */ 763 CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_); 764 } 765 766 static void 767 nix_sq_ctx_cn10k(volatile void *qctx, struct plt_tel_data *d) 768 { 769 volatile struct nix_cn10k_sq_ctx_s *ctx; 770 771 ctx = (volatile struct nix_cn10k_sq_ctx_s *)qctx; 772 773 /* W0 */ 774 CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_); 775 CNXK_TEL_DICT_INT(d, ctx, cq, w0_); 776 CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_); 777 CNXK_TEL_DICT_INT(d, ctx, substream, w0_); 778 CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_); 779 CNXK_TEL_DICT_INT(d, ctx, ena, w0_); 780 781 /* W1 */ 782 CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_lb, w1_); 783 CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_); 784 CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_); 785 CNXK_TEL_DICT_INT(d, ctx, smq_rr_weight, w1_); 786 CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_); 787 CNXK_TEL_DICT_INT(d, ctx, xoff, w1_); 788 CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_); 789 CNXK_TEL_DICT_INT(d, ctx, smq, w1_); 790 791 /* W2 */ 792 CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_); 793 CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_); 794 CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_); 795 CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_); 796 CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_ub, w2_); 797 798 /* W3 */ 799 CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_); 800 CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_); 801 CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_); 802 CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_); 803 CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_); 804 CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_); 805 CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_); 806 CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_); 807 CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_); 808 CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_); 809 CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_); 810 CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_); 811 812 /* W4 */ 813 CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_); 814 815 /* W5 */ 816 CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_); 817 818 /* W6 */ 819 CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_); 820 821 /* W7 */ 822 CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_); 823 824 /* W8 */ 825 CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_); 826 827 /* W9 */ 828 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_); 829 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_); 830 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_); 831 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_); 832 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_); 833 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_); 834 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_); 835 836 /* W10 */ 837 CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_); 838 839 /* W11 */ 840 CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_); 841 842 /* W12 */ 843 CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_); 844 845 /* W13 */ 846 CNXK_TEL_DICT_INT(d, ctx, aged_drop_octs, w13_); 847 CNXK_TEL_DICT_INT(d, ctx, aged_drop_pkts, w13_); 848 849 /* W14 */ 850 CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_); 851 852 /* W15 */ 853 CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_); 854 } 855 856 static void 857 nix_sq_ctx(volatile void *qctx, struct plt_tel_data *d) 858 { 859 volatile struct nix_cn20k_sq_ctx_s *ctx; 860 861 ctx = (volatile struct nix_cn20k_sq_ctx_s *)qctx; 862 863 /* W0 */ 864 CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_); 865 CNXK_TEL_DICT_INT(d, ctx, cq, w0_); 866 CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_); 867 CNXK_TEL_DICT_INT(d, ctx, substream, w0_); 868 CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_); 869 CNXK_TEL_DICT_INT(d, ctx, ena, w0_); 870 871 /* W1 */ 872 CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_lb, w1_); 873 CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_); 874 CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_); 875 CNXK_TEL_DICT_INT(d, ctx, smq_rr_weight, w1_); 876 CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_); 877 CNXK_TEL_DICT_INT(d, ctx, xoff, w1_); 878 CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_); 879 CNXK_TEL_DICT_INT(d, ctx, smq, w1_); 880 881 /* W2 */ 882 CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_); 883 CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_); 884 CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_); 885 CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_); 886 CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_ub, w2_); 887 888 /* W3 */ 889 CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_); 890 CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_); 891 CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_); 892 CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_); 893 CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_); 894 CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_); 895 CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_); 896 CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_); 897 CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_); 898 CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_); 899 CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_); 900 CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_); 901 902 /* W4 */ 903 CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_); 904 905 /* W5 */ 906 CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_); 907 908 /* W6 */ 909 CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_); 910 911 /* W7 */ 912 CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_); 913 914 /* W8 */ 915 CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_); 916 917 /* W9 */ 918 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_); 919 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_); 920 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_); 921 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_); 922 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_); 923 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_); 924 CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_); 925 926 /* W10 */ 927 CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_); 928 929 /* W11 */ 930 CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_); 931 932 /* W12 */ 933 CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_); 934 935 /* W13 */ 936 CNXK_TEL_DICT_INT(d, ctx, aged_drop_octs, w13_); 937 CNXK_TEL_DICT_INT(d, ctx, aged_drop_pkts, w13_); 938 939 /* W14 */ 940 CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_); 941 942 /* W15 */ 943 CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_); 944 } 945 946 static int 947 cnxk_tel_nix_sq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d) 948 { 949 struct nix *nix = roc_nix_to_nix_priv(roc_nix); 950 struct dev *dev = &nix->dev; 951 struct npa_lf *npa_lf; 952 volatile void *qctx; 953 int rc = -1; 954 955 npa_lf = idev_npa_obj_get(); 956 if (npa_lf == NULL) 957 return NPA_ERR_DEVICE_NOT_BOUNDED; 958 959 rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_SQ, n, &qctx); 960 if (rc) { 961 plt_err("Failed to get rq context"); 962 return rc; 963 } 964 965 if (roc_model_is_cn9k()) 966 nix_sq_ctx_cn9k(qctx, d); 967 else if (roc_model_is_cn10k()) 968 nix_sq_ctx_cn10k(qctx, d); 969 else 970 nix_sq_ctx(qctx, d); 971 972 return 0; 973 } 974 975 static int 976 cnxk_nix_tel_handle_list(const char *cmd __plt_unused, 977 const char *params __plt_unused, 978 struct plt_tel_data *d) 979 { 980 struct nix_tel_node *node; 981 struct roc_nix *roc_nix; 982 983 plt_tel_data_start_array(d, PLT_TEL_STRING_VAL); 984 985 TAILQ_FOREACH(node, &nix_list, node) { 986 roc_nix = node->nix; 987 plt_tel_data_add_array_string(d, roc_nix->pci_dev->name); 988 } 989 990 return 0; 991 } 992 993 static int 994 cnxk_nix_tel_handle_info(const char *cmd __plt_unused, const char *params, 995 struct plt_tel_data *d) 996 { 997 char name[PCI_PRI_STR_SIZE]; 998 struct nix_tel_node *node; 999 1000 if (params == NULL || strlen(params) == 0 || !isdigit(*params)) 1001 return -1; 1002 1003 plt_strlcpy(name, params, PCI_PRI_STR_SIZE); 1004 1005 node = nix_tel_node_get_by_pcidev_name(name); 1006 if (!node) 1007 return -1; 1008 1009 plt_tel_data_start_dict(d); 1010 return cnxk_tel_nix(node->nix, d); 1011 } 1012 1013 static int 1014 cnxk_nix_tel_handle_info_x(const char *cmd, const char *params, 1015 struct plt_tel_data *d) 1016 { 1017 struct nix_tel_node *node; 1018 char *name, *param; 1019 char buf[1024]; 1020 int rc = -1; 1021 1022 if (params == NULL || strlen(params) == 0 || !isdigit(*params)) 1023 goto exit; 1024 1025 plt_strlcpy(buf, params, PCI_PRI_STR_SIZE + 1); 1026 name = strtok(buf, ","); 1027 if (name == NULL) 1028 goto exit; 1029 1030 param = strtok(NULL, "\0"); 1031 1032 node = nix_tel_node_get_by_pcidev_name(name); 1033 if (!node) 1034 goto exit; 1035 1036 plt_tel_data_start_dict(d); 1037 1038 if (strstr(cmd, "rq")) { 1039 char *tok = strtok(param, ","); 1040 int rq; 1041 1042 if (!tok) 1043 goto exit; 1044 1045 rq = strtol(tok, NULL, 10); 1046 if ((node->n_rq <= rq) || (rq < 0)) 1047 goto exit; 1048 1049 if (strstr(cmd, "ctx")) 1050 rc = cnxk_tel_nix_rq_ctx(node->nix, rq, d); 1051 else 1052 rc = cnxk_tel_nix_rq(node->rqs[rq], d); 1053 1054 } else if (strstr(cmd, "cq")) { 1055 char *tok = strtok(param, ","); 1056 int cq; 1057 1058 if (!tok) 1059 goto exit; 1060 1061 cq = strtol(tok, NULL, 10); 1062 if ((node->n_cq <= cq) || (cq < 0)) 1063 goto exit; 1064 1065 if (strstr(cmd, "ctx")) 1066 rc = cnxk_tel_nix_cq_ctx(node->nix, cq, d); 1067 else 1068 rc = cnxk_tel_nix_cq(node->cqs[cq], d); 1069 1070 } else if (strstr(cmd, "sq")) { 1071 char *tok = strtok(param, ","); 1072 int sq; 1073 1074 if (!tok) 1075 goto exit; 1076 1077 sq = strtol(tok, NULL, 10); 1078 if ((node->n_sq <= sq) || (sq < 0)) 1079 goto exit; 1080 1081 if (strstr(cmd, "ctx")) 1082 rc = cnxk_tel_nix_sq_ctx(node->nix, sq, d); 1083 else 1084 rc = cnxk_tel_nix_sq(node->sqs[sq], d); 1085 } 1086 1087 exit: 1088 return rc; 1089 } 1090 1091 PLT_INIT(cnxk_telemetry_nix_init) 1092 { 1093 TAILQ_INIT(&nix_list); 1094 1095 plt_telemetry_register_cmd( 1096 "/cnxk/nix/list", cnxk_nix_tel_handle_list, 1097 "Returns list of available NIX devices. Takes no parameters"); 1098 plt_telemetry_register_cmd( 1099 "/cnxk/nix/info", cnxk_nix_tel_handle_info, 1100 "Returns nix information. Parameters: pci id"); 1101 plt_telemetry_register_cmd( 1102 "/cnxk/nix/rq/info", cnxk_nix_tel_handle_info_x, 1103 "Returns nix rq information. Parameters: pci id, rq id"); 1104 plt_telemetry_register_cmd( 1105 "/cnxk/nix/rq/ctx", cnxk_nix_tel_handle_info_x, 1106 "Returns nix rq context. Parameters: pci id, rq id"); 1107 plt_telemetry_register_cmd( 1108 "/cnxk/nix/cq/info", cnxk_nix_tel_handle_info_x, 1109 "Returns nix cq information. Parameters: pci id, cq id"); 1110 plt_telemetry_register_cmd( 1111 "/cnxk/nix/cq/ctx", cnxk_nix_tel_handle_info_x, 1112 "Returns nix cq context. Parameters: pci id, cq id"); 1113 plt_telemetry_register_cmd( 1114 "/cnxk/nix/sq/info", cnxk_nix_tel_handle_info_x, 1115 "Returns nix sq information. Parameters: pci id, sq id"); 1116 plt_telemetry_register_cmd( 1117 "/cnxk/nix/sq/ctx", cnxk_nix_tel_handle_info_x, 1118 "Returns nix sq context. Parameters: pci id, sq id"); 1119 } 1120