1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2017 Intel Corporation
*/
#include <stdint.h>
#include <eal_export.h>
#include <rte_errno.h>
#include "ethdev_trace.h"
#include "rte_ethdev.h"
#include "rte_tm_driver.h"
#include "rte_tm.h"
/* Get generic traffic manager operations structure from a port. */
const struct rte_tm_ops *
rte_tm_ops_get(uint16_t port_id, struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
const struct rte_tm_ops *ops;
if (!rte_eth_dev_is_valid_port(port_id)) {
rte_tm_error_set(error,
ENODEV,
RTE_TM_ERROR_TYPE_UNSPECIFIED,
NULL,
rte_strerror(ENODEV));
return NULL;
}
if ((dev->dev_ops->tm_ops_get == NULL) ||
(dev->dev_ops->tm_ops_get(dev, &ops) != 0) ||
(ops == NULL)) {
rte_tm_error_set(error,
ENOSYS,
RTE_TM_ERROR_TYPE_UNSPECIFIED,
NULL,
rte_strerror(ENOSYS));
return NULL;
}
return ops;
}
#define RTE_TM_FUNC(port_id, func) \
__extension__ ({ \
const struct rte_tm_ops *ops = \
rte_tm_ops_get(port_id, error); \
if (ops == NULL) \
return -rte_errno; \
\
if (ops->func == NULL) \
return -rte_tm_error_set(error, \
ENOSYS, \
RTE_TM_ERROR_TYPE_UNSPECIFIED, \
NULL, \
rte_strerror(ENOSYS)); \
\
ops->func; \
})
/* Get number of leaf nodes */
RTE_EXPORT_SYMBOL(rte_tm_get_number_of_leaf_nodes)
int
rte_tm_get_number_of_leaf_nodes(uint16_t port_id,
uint32_t *n_leaf_nodes,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
const struct rte_tm_ops *ops =
rte_tm_ops_get(port_id, error);
if (ops == NULL)
return -rte_errno;
if (n_leaf_nodes == NULL) {
rte_tm_error_set(error,
EINVAL,
RTE_TM_ERROR_TYPE_UNSPECIFIED,
NULL,
rte_strerror(EINVAL));
return -rte_errno;
}
*n_leaf_nodes = dev->data->nb_tx_queues;
rte_tm_trace_get_number_of_leaf_nodes(port_id, *n_leaf_nodes);
return 0;
}
/* Check node type (leaf or non-leaf) */
RTE_EXPORT_SYMBOL(rte_tm_node_type_get)
int
rte_tm_node_type_get(uint16_t port_id,
uint32_t node_id,
int *is_leaf,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_type_get)(dev,
node_id, is_leaf, error);
rte_tm_trace_node_type_get(port_id, node_id, *is_leaf, ret);
return ret;
}
/* Get capabilities */
RTE_EXPORT_SYMBOL(rte_tm_capabilities_get)
int rte_tm_capabilities_get(uint16_t port_id,
struct rte_tm_capabilities *cap,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, capabilities_get)(dev,
cap, error);
rte_tm_trace_capabilities_get(port_id, cap, ret);
return ret;
}
/* Get level capabilities */
RTE_EXPORT_SYMBOL(rte_tm_level_capabilities_get)
int rte_tm_level_capabilities_get(uint16_t port_id,
uint32_t level_id,
struct rte_tm_level_capabilities *cap,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, level_capabilities_get)(dev,
level_id, cap, error);
rte_tm_trace_level_capabilities_get(port_id, level_id, cap, ret);
return ret;
}
/* Get node capabilities */
RTE_EXPORT_SYMBOL(rte_tm_node_capabilities_get)
int rte_tm_node_capabilities_get(uint16_t port_id,
uint32_t node_id,
struct rte_tm_node_capabilities *cap,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_capabilities_get)(dev,
node_id, cap, error);
rte_tm_trace_node_capabilities_get(port_id, node_id, cap, ret);
return ret;
}
/* Add WRED profile */
RTE_EXPORT_SYMBOL(rte_tm_wred_profile_add)
int rte_tm_wred_profile_add(uint16_t port_id,
uint32_t wred_profile_id,
const struct rte_tm_wred_params *profile,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, wred_profile_add)(dev,
wred_profile_id, profile, error);
rte_tm_trace_wred_profile_add(port_id, wred_profile_id, profile, ret);
return ret;
}
/* Delete WRED profile */
RTE_EXPORT_SYMBOL(rte_tm_wred_profile_delete)
int rte_tm_wred_profile_delete(uint16_t port_id,
uint32_t wred_profile_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, wred_profile_delete)(dev,
wred_profile_id, error);
rte_tm_trace_wred_profile_delete(port_id, wred_profile_id, ret);
return ret;
}
/* Add/update shared WRED context */
RTE_EXPORT_SYMBOL(rte_tm_shared_wred_context_add_update)
int rte_tm_shared_wred_context_add_update(uint16_t port_id,
uint32_t shared_wred_context_id,
uint32_t wred_profile_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, shared_wred_context_add_update)(dev,
shared_wred_context_id, wred_profile_id, error);
rte_tm_trace_shared_wred_context_add_update(port_id,
shared_wred_context_id,
wred_profile_id, ret);
return ret;
}
/* Delete shared WRED context */
RTE_EXPORT_SYMBOL(rte_tm_shared_wred_context_delete)
int rte_tm_shared_wred_context_delete(uint16_t port_id,
uint32_t shared_wred_context_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, shared_wred_context_delete)(dev,
shared_wred_context_id, error);
rte_tm_trace_shared_wred_context_delete(port_id,
shared_wred_context_id, ret);
return ret;
}
/* Add shaper profile */
RTE_EXPORT_SYMBOL(rte_tm_shaper_profile_add)
int rte_tm_shaper_profile_add(uint16_t port_id,
uint32_t shaper_profile_id,
const struct rte_tm_shaper_params *profile,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, shaper_profile_add)(dev,
shaper_profile_id, profile, error);
rte_tm_trace_shaper_profile_add(port_id, shaper_profile_id, profile,
ret);
return ret;
}
/* Delete WRED profile */
RTE_EXPORT_SYMBOL(rte_tm_shaper_profile_delete)
int rte_tm_shaper_profile_delete(uint16_t port_id,
uint32_t shaper_profile_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, shaper_profile_delete)(dev,
shaper_profile_id, error);
rte_tm_trace_shaper_profile_delete(port_id, shaper_profile_id, ret);
return ret;
}
/* Add shared shaper */
RTE_EXPORT_SYMBOL(rte_tm_shared_shaper_add_update)
int rte_tm_shared_shaper_add_update(uint16_t port_id,
uint32_t shared_shaper_id,
uint32_t shaper_profile_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, shared_shaper_add_update)(dev,
shared_shaper_id, shaper_profile_id, error);
rte_tm_trace_shared_shaper_add_update(port_id, shared_shaper_id,
shaper_profile_id, ret);
return ret;
}
/* Delete shared shaper */
RTE_EXPORT_SYMBOL(rte_tm_shared_shaper_delete)
int rte_tm_shared_shaper_delete(uint16_t port_id,
uint32_t shared_shaper_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, shared_shaper_delete)(dev,
shared_shaper_id, error);
rte_tm_trace_shared_shaper_delete(port_id, shared_shaper_id, ret);
return ret;
}
/* Add node to port traffic manager hierarchy */
RTE_EXPORT_SYMBOL(rte_tm_node_add)
int rte_tm_node_add(uint16_t port_id,
uint32_t node_id,
uint32_t parent_node_id,
uint32_t priority,
uint32_t weight,
uint32_t level_id,
const struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_add)(dev,
node_id, parent_node_id, priority, weight, level_id,
params, error);
rte_tm_trace_node_add(port_id, node_id, parent_node_id, priority,
weight, level_id, params, ret);
return ret;
}
RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_tm_node_query, 24.11)
int rte_tm_node_query(uint16_t port_id,
uint32_t node_id,
uint32_t *parent_node_id,
uint32_t *priority,
uint32_t *weight,
uint32_t *level_id,
struct rte_tm_node_params *params,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_query)(dev,
node_id, parent_node_id, priority, weight, level_id,
params, error);
rte_tm_trace_node_query(port_id, node_id, parent_node_id, priority,
weight, level_id, params, ret);
return ret;
}
/* Delete node from traffic manager hierarchy */
RTE_EXPORT_SYMBOL(rte_tm_node_delete)
int rte_tm_node_delete(uint16_t port_id,
uint32_t node_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_delete)(dev,
node_id, error);
rte_tm_trace_node_delete(port_id, node_id, ret);
return ret;
}
/* Suspend node */
RTE_EXPORT_SYMBOL(rte_tm_node_suspend)
int rte_tm_node_suspend(uint16_t port_id,
uint32_t node_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_suspend)(dev,
node_id, error);
rte_tm_trace_node_suspend(port_id, node_id, ret);
return ret;
}
/* Resume node */
RTE_EXPORT_SYMBOL(rte_tm_node_resume)
int rte_tm_node_resume(uint16_t port_id,
uint32_t node_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_resume)(dev,
node_id, error);
rte_tm_trace_node_resume(port_id, node_id, ret);
return ret;
}
/* Commit the initial port traffic manager hierarchy */
RTE_EXPORT_SYMBOL(rte_tm_hierarchy_commit)
int rte_tm_hierarchy_commit(uint16_t port_id,
int clear_on_fail,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, hierarchy_commit)(dev,
clear_on_fail, error);
rte_tm_trace_hierarchy_commit(port_id, clear_on_fail, ret);
return ret;
}
/* Update node parent */
RTE_EXPORT_SYMBOL(rte_tm_node_parent_update)
int rte_tm_node_parent_update(uint16_t port_id,
uint32_t node_id,
uint32_t parent_node_id,
uint32_t priority,
uint32_t weight,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_parent_update)(dev,
node_id, parent_node_id, priority, weight, error);
rte_tm_trace_node_parent_update(port_id, node_id, parent_node_id,
priority, weight, ret);
return ret;
}
/* Update node private shaper */
RTE_EXPORT_SYMBOL(rte_tm_node_shaper_update)
int rte_tm_node_shaper_update(uint16_t port_id,
uint32_t node_id,
uint32_t shaper_profile_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_shaper_update)(dev,
node_id, shaper_profile_id, error);
rte_tm_trace_node_shaper_update(port_id, node_id, shaper_profile_id,
ret);
return ret;
}
/* Update node shared shapers */
RTE_EXPORT_SYMBOL(rte_tm_node_shared_shaper_update)
int rte_tm_node_shared_shaper_update(uint16_t port_id,
uint32_t node_id,
uint32_t shared_shaper_id,
int add,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_shared_shaper_update)(dev,
node_id, shared_shaper_id, add, error);
rte_tm_trace_node_shared_shaper_update(port_id, node_id,
shared_shaper_id, add, ret);
return ret;
}
/* Update node stats */
RTE_EXPORT_SYMBOL(rte_tm_node_stats_update)
int rte_tm_node_stats_update(uint16_t port_id,
uint32_t node_id,
uint64_t stats_mask,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_stats_update)(dev,
node_id, stats_mask, error);
rte_tm_trace_node_stats_update(port_id, node_id, stats_mask, ret);
return ret;
}
/* Update WFQ weight mode */
RTE_EXPORT_SYMBOL(rte_tm_node_wfq_weight_mode_update)
int rte_tm_node_wfq_weight_mode_update(uint16_t port_id,
uint32_t node_id,
int *wfq_weight_mode,
uint32_t n_sp_priorities,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_wfq_weight_mode_update)(dev,
node_id, wfq_weight_mode, n_sp_priorities, error);
rte_tm_trace_node_wfq_weight_mode_update(port_id, node_id,
wfq_weight_mode,
n_sp_priorities, ret);
return ret;
}
/* Update node congestion management mode */
RTE_EXPORT_SYMBOL(rte_tm_node_cman_update)
int rte_tm_node_cman_update(uint16_t port_id,
uint32_t node_id,
enum rte_tm_cman_mode cman,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_cman_update)(dev,
node_id, cman, error);
rte_tm_trace_node_cman_update(port_id, node_id, cman, ret);
return ret;
}
/* Update node private WRED context */
RTE_EXPORT_SYMBOL(rte_tm_node_wred_context_update)
int rte_tm_node_wred_context_update(uint16_t port_id,
uint32_t node_id,
uint32_t wred_profile_id,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_wred_context_update)(dev,
node_id, wred_profile_id, error);
rte_tm_trace_node_wred_context_update(port_id, node_id, wred_profile_id,
ret);
return ret;
}
/* Update node shared WRED context */
RTE_EXPORT_SYMBOL(rte_tm_node_shared_wred_context_update)
int rte_tm_node_shared_wred_context_update(uint16_t port_id,
uint32_t node_id,
uint32_t shared_wred_context_id,
int add,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_shared_wred_context_update)(dev,
node_id, shared_wred_context_id, add, error);
rte_tm_trace_node_shared_wred_context_update(port_id, node_id,
shared_wred_context_id,
add, ret);
return ret;
}
/* Read and/or clear stats counters for specific node */
RTE_EXPORT_SYMBOL(rte_tm_node_stats_read)
int rte_tm_node_stats_read(uint16_t port_id,
uint32_t node_id,
struct rte_tm_node_stats *stats,
uint64_t *stats_mask,
int clear,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, node_stats_read)(dev,
node_id, stats, stats_mask, clear, error);
rte_tm_trace_node_stats_read(port_id, node_id, stats, *stats_mask,
clear, ret);
return ret;
}
/* Packet marking - VLAN DEI */
RTE_EXPORT_SYMBOL(rte_tm_mark_vlan_dei)
int rte_tm_mark_vlan_dei(uint16_t port_id,
int mark_green,
int mark_yellow,
int mark_red,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, mark_vlan_dei)(dev,
mark_green, mark_yellow, mark_red, error);
rte_tm_trace_mark_vlan_dei(port_id, mark_green, mark_yellow, mark_red,
ret);
return ret;
}
/* Packet marking - IPv4/IPv6 ECN */
RTE_EXPORT_SYMBOL(rte_tm_mark_ip_ecn)
int rte_tm_mark_ip_ecn(uint16_t port_id,
int mark_green,
int mark_yellow,
int mark_red,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, mark_ip_ecn)(dev,
mark_green, mark_yellow, mark_red, error);
rte_tm_trace_mark_ip_ecn(port_id, mark_green, mark_yellow, mark_red,
ret);
return ret;
}
/* Packet marking - IPv4/IPv6 DSCP */
RTE_EXPORT_SYMBOL(rte_tm_mark_ip_dscp)
int rte_tm_mark_ip_dscp(uint16_t port_id,
int mark_green,
int mark_yellow,
int mark_red,
struct rte_tm_error *error)
{
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
int ret;
ret = RTE_TM_FUNC(port_id, mark_ip_dscp)(dev,
mark_green, mark_yellow, mark_red, error);
rte_tm_trace_mark_ip_dscp(port_id, mark_green, mark_yellow, mark_red,
ret);
return ret;
}
|