cxgbetool.c (ffcf81c99d1cf9a6f7c93b24d0cde044e7ff9231) | cxgbetool.c (6ba813531f285d8fe6db628ef0c128b96f52683c) |
---|---|
1/*- 2 * Copyright (c) 2011 Chelsio Communications, Inc. 3 * All rights reserved. 4 * Written by: Navdeep Parhar <np@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 80 unchanged lines hidden (view full) --- 89usage(FILE *fp) 90{ 91 fprintf(fp, "Usage: %s <nexus> [operation]\n", progname); 92 fprintf(fp, 93 "\tclearstats <port> clear port statistics\n" 94 "\tcontext <type> <id> show an SGE context\n" 95 "\tdumpstate <dump.bin> dump chip state\n" 96 "\tfilter <idx> [<param> <val>] ... set a filter\n" | 1/*- 2 * Copyright (c) 2011 Chelsio Communications, Inc. 3 * All rights reserved. 4 * Written by: Navdeep Parhar <np@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 80 unchanged lines hidden (view full) --- 89usage(FILE *fp) 90{ 91 fprintf(fp, "Usage: %s <nexus> [operation]\n", progname); 92 fprintf(fp, 93 "\tclearstats <port> clear port statistics\n" 94 "\tcontext <type> <id> show an SGE context\n" 95 "\tdumpstate <dump.bin> dump chip state\n" 96 "\tfilter <idx> [<param> <val>] ... set a filter\n" |
97 "\tfilter <idx> delete|clear delete a filter\n" | 97 "\tfilter <idx> delete|clear [prio 1] delete a filter\n" |
98 "\tfilter list list all filters\n" 99 "\tfilter mode [<match>] ... get/set global filter mode\n" 100 "\thashfilter [<param> <val>] ... set a hashfilter\n" 101 "\thashfilter <idx> delete|clear delete a hashfilter\n" 102 "\thashfilter list list all hashfilters\n" 103 "\thashfilter mode get global hashfilter mode\n" 104 "\ti2c <port> <devaddr> <addr> [<len>] read from i2c device\n" 105 "\tloadboot <bi.bin> [pf|offset <val>] install boot image\n" --- 36 unchanged lines hidden (view full) --- 142 char buf[64]; 143 144 snprintf(buf, sizeof(buf), "/dev/%s", nexus); 145 if ((fd = open(buf, O_RDWR)) < 0) { 146 warn("open(%s)", nexus); 147 rc = errno; 148 return (rc); 149 } | 98 "\tfilter list list all filters\n" 99 "\tfilter mode [<match>] ... get/set global filter mode\n" 100 "\thashfilter [<param> <val>] ... set a hashfilter\n" 101 "\thashfilter <idx> delete|clear delete a hashfilter\n" 102 "\thashfilter list list all hashfilters\n" 103 "\thashfilter mode get global hashfilter mode\n" 104 "\ti2c <port> <devaddr> <addr> [<len>] read from i2c device\n" 105 "\tloadboot <bi.bin> [pf|offset <val>] install boot image\n" --- 36 unchanged lines hidden (view full) --- 142 char buf[64]; 143 144 snprintf(buf, sizeof(buf), "/dev/%s", nexus); 145 if ((fd = open(buf, O_RDWR)) < 0) { 146 warn("open(%s)", nexus); 147 rc = errno; 148 return (rc); 149 } |
150 chip_id = nexus[1] - '0'; | |
151 } 152 153 rc = ioctl(fd, cmd, data); 154 if (rc < 0) { 155 warn("%s", cmdstr); 156 rc = errno; 157 } 158 --- 770 unchanged lines hidden (view full) --- 929 } else { 930 printf("%d", t->fs.iq); 931 if (t->fs.dirsteerhash == 0) 932 printf("(QID)"); 933 else 934 printf("(hash)"); 935 } 936 } | 150 } 151 152 rc = ioctl(fd, cmd, data); 153 if (rc < 0) { 154 warn("%s", cmdstr); 155 rc = errno; 156 } 157 --- 770 unchanged lines hidden (view full) --- 928 } else { 929 printf("%d", t->fs.iq); 930 if (t->fs.dirsteerhash == 0) 931 printf("(QID)"); 932 else 933 printf("(hash)"); 934 } 935 } |
937 if (t->fs.prio) | 936 if (chip_id <= 5 && t->fs.prio) |
938 printf(" Prio"); 939 if (t->fs.rpttid) 940 printf(" RptTID"); 941 printf("\n"); 942} 943 944static int 945show_filters(int hash) 946{ | 937 printf(" Prio"); 938 if (t->fs.rpttid) 939 printf(" RptTID"); 940 printf("\n"); 941} 942 943static int 944show_filters(int hash) 945{ |
947 uint32_t mode = 0, header = 0; | 946 uint32_t mode = 0, header, hpfilter = 0; |
948 struct t4_filter t; 949 int rc; 950 951 /* Get the global filter mode first */ 952 rc = doit(CHELSIO_T4_GET_FILTER_MODE, &mode); 953 if (rc != 0) 954 return (rc); 955 | 947 struct t4_filter t; 948 int rc; 949 950 /* Get the global filter mode first */ 951 rc = doit(CHELSIO_T4_GET_FILTER_MODE, &mode); 952 if (rc != 0) 953 return (rc); 954 |
955 if (!hash && chip_id >= 6) { 956 header = 0; 957 bzero(&t, sizeof (t)); 958 t.idx = 0; 959 t.fs.hash = 0; 960 t.fs.prio = 1; 961 for (t.idx = 0; ; t.idx++) { 962 rc = doit(CHELSIO_T4_GET_FILTER, &t); 963 if (rc != 0 || t.idx == 0xffffffff) 964 break; 965 966 if (!header) { 967 printf("High Priority TCAM Region:\n"); 968 do_show_info_header(mode); 969 header = 1; 970 hpfilter = 1; 971 } 972 do_show_one_filter_info(&t, mode); 973 } 974 } 975 976 header = 0; 977 bzero(&t, sizeof (t)); |
|
956 t.idx = 0; 957 t.fs.hash = hash; 958 for (t.idx = 0; ; t.idx++) { 959 rc = doit(CHELSIO_T4_GET_FILTER, &t); 960 if (rc != 0 || t.idx == 0xffffffff) 961 break; 962 963 if (!header) { | 978 t.idx = 0; 979 t.fs.hash = hash; 980 for (t.idx = 0; ; t.idx++) { 981 rc = doit(CHELSIO_T4_GET_FILTER, &t); 982 if (rc != 0 || t.idx == 0xffffffff) 983 break; 984 985 if (!header) { |
986 if (hpfilter) 987 printf("\nNormal Priority TCAM Region:\n"); |
|
964 do_show_info_header(mode); 965 header = 1; 966 } 967 do_show_one_filter_info(&t, mode); | 988 do_show_info_header(mode); 989 header = 1; 990 } 991 do_show_one_filter_info(&t, mode); |
968 }; | 992 } |
969 970 return (rc); 971} 972 973static int 974get_filter_mode(int hashfilter) 975{ 976 uint32_t mode = hashfilter; --- 110 unchanged lines hidden (view full) --- 1087 warnx("\"vnic_id\" and \"ovlan\" are mutually exclusive."); 1088 return (EINVAL); 1089 } 1090 1091 return doit(CHELSIO_T4_SET_FILTER_MODE, &mode); 1092} 1093 1094static int | 993 994 return (rc); 995} 996 997static int 998get_filter_mode(int hashfilter) 999{ 1000 uint32_t mode = hashfilter; --- 110 unchanged lines hidden (view full) --- 1111 warnx("\"vnic_id\" and \"ovlan\" are mutually exclusive."); 1112 return (EINVAL); 1113 } 1114 1115 return doit(CHELSIO_T4_SET_FILTER_MODE, &mode); 1116} 1117 1118static int |
1095del_filter(uint32_t idx, int hashfilter) | 1119del_filter(uint32_t idx, int prio, int hashfilter) |
1096{ 1097 struct t4_filter t; 1098 | 1120{ 1121 struct t4_filter t; 1122 |
1123 t.fs.prio = prio; |
|
1099 t.fs.hash = hashfilter; 1100 t.idx = idx; 1101 1102 return doit(CHELSIO_T4_DEL_FILTER, &t); 1103} 1104 1105#define MAX_VLANID (4095) 1106 --- 113 unchanged lines hidden (view full) --- 1220 warnx("invalid action \"%s\"; must be one of" 1221 " \"pass\", \"drop\" or \"switch\"", 1222 argv[start_arg + 1]); 1223 return (EINVAL); 1224 } 1225 } else if (!parse_val("hitcnts", args, &val)) { 1226 t.fs.hitcnts = val; 1227 } else if (!parse_val("prio", args, &val)) { | 1124 t.fs.hash = hashfilter; 1125 t.idx = idx; 1126 1127 return doit(CHELSIO_T4_DEL_FILTER, &t); 1128} 1129 1130#define MAX_VLANID (4095) 1131 --- 113 unchanged lines hidden (view full) --- 1245 warnx("invalid action \"%s\"; must be one of" 1246 " \"pass\", \"drop\" or \"switch\"", 1247 argv[start_arg + 1]); 1248 return (EINVAL); 1249 } 1250 } else if (!parse_val("hitcnts", args, &val)) { 1251 t.fs.hitcnts = val; 1252 } else if (!parse_val("prio", args, &val)) { |
1253 if (hash) { 1254 warnx("Hashfilters doesn't support \"prio\"\n"); 1255 return (EINVAL); 1256 } 1257 if (val != 0 && val != 1) { 1258 warnx("invalid priority \"%s\"; must be" 1259 " \"0\" or \"1\"", argv[start_arg + 1]); 1260 return (EINVAL); 1261 } |
|
1228 t.fs.prio = val; 1229 } else if (!parse_val("rpttid", args, &val)) { 1230 t.fs.rpttid = 1; 1231 } else if (!parse_val("queue", args, &val)) { 1232 t.fs.dirsteer = 1; 1233 t.fs.iq = val; 1234 } else if (!parse_val("tcbhash", args, &val)) { 1235 t.fs.maskhash = 1; --- 165 unchanged lines hidden (view full) --- 1401 goto setf; 1402 } 1403 warnx("\"%s\" is neither an index nor a filter subcommand.", 1404 argv[0]); 1405 return (EINVAL); 1406 } 1407 idx = (uint32_t) val; 1408 | 1262 t.fs.prio = val; 1263 } else if (!parse_val("rpttid", args, &val)) { 1264 t.fs.rpttid = 1; 1265 } else if (!parse_val("queue", args, &val)) { 1266 t.fs.dirsteer = 1; 1267 t.fs.iq = val; 1268 } else if (!parse_val("tcbhash", args, &val)) { 1269 t.fs.maskhash = 1; --- 165 unchanged lines hidden (view full) --- 1435 goto setf; 1436 } 1437 warnx("\"%s\" is neither an index nor a filter subcommand.", 1438 argv[0]); 1439 return (EINVAL); 1440 } 1441 idx = (uint32_t) val; 1442 |
1409 /* <idx> delete|clear */ 1410 if (argc == 2 && | 1443 /* <idx> delete|clear [prio 0|1] */ 1444 if ((argc == 2 || argc == 4) && |
1411 (strcmp(argv[1], "delete") == 0 || strcmp(argv[1], "clear") == 0)) { | 1445 (strcmp(argv[1], "delete") == 0 || strcmp(argv[1], "clear") == 0)) { |
1412 return del_filter(idx, hashfilter); | 1446 int prio = 0; 1447 1448 if (argc == 4) { 1449 if (hashfilter) { 1450 warnx("stray arguments after \"%s\".", argv[1]); 1451 return (EINVAL); 1452 } 1453 1454 if (strcmp(argv[2], "prio") != 0) { 1455 warnx("\"prio\" is the only valid keyword " 1456 "after \"%s\", found \"%s\" instead.", 1457 argv[1], argv[2]); 1458 return (EINVAL); 1459 } 1460 1461 s = str_to_number(argv[3], NULL, &val); 1462 if (*s || val < 0 || val > 1) { 1463 warnx("%s \"%s\"; must be \"0\" or \"1\".", 1464 argv[2], argv[3]); 1465 return (EINVAL); 1466 } 1467 prio = (int)val; 1468 } 1469 return del_filter(idx, prio, hashfilter); |
1413 } 1414 1415 /* skip <idx> */ 1416 argc--; 1417 argv++; 1418 1419setf: 1420 /* [<param> <val>] ... */ --- 2131 unchanged lines hidden (view full) --- 3552 } 3553 3554 if (argc < 3) { 3555 usage(stderr); 3556 exit(EINVAL); 3557 } 3558 3559 nexus = argv[1]; | 1470 } 1471 1472 /* skip <idx> */ 1473 argc--; 1474 argv++; 1475 1476setf: 1477 /* [<param> <val>] ... */ --- 2131 unchanged lines hidden (view full) --- 3609 } 3610 3611 if (argc < 3) { 3612 usage(stderr); 3613 exit(EINVAL); 3614 } 3615 3616 nexus = argv[1]; |
3617 chip_id = nexus[1] - '0'; |
|
3560 3561 /* progname and nexus */ 3562 argc -= 2; 3563 argv += 2; 3564 3565 if (argc == 1 && !strcmp(argv[0], "stdio")) 3566 rc = run_cmd_loop(); 3567 else 3568 rc = run_cmd(argc, argv); 3569 3570 return (rc); 3571} | 3618 3619 /* progname and nexus */ 3620 argc -= 2; 3621 argv += 2; 3622 3623 if (argc == 1 && !strcmp(argv[0], "stdio")) 3624 rc = run_cmd_loop(); 3625 else 3626 rc = run_cmd(argc, argv); 3627 3628 return (rc); 3629} |