Lines Matching +full:const +full:- +full:op +full:- +full:mode

1 /*-
61 const char *progname, *nexus;
72 const char *name;
78 const char *name;
79 const struct reg_info *ri;
83 const char *name; /* Field name */
88 unsigned char islog2; /* Field contains the base-2 log of the value */
110 "\tfilter mode [<match>] ... get/set global filter mode\n"
114 "\thashfilter mode [<match>] ... get/set global hashfilter mode\n"
118 "\tloadboot-cfg <bc.bin> install boot config\n"
119 "\tloadboot-cfg clear remove boot config\n"
120 "\tloadcfg <fw-config.txt> install configuration file\n"
122 "\tloadfw <fw-image.bin> install firmware\n"
130 "\tsched-class params <param> <val> .. configure TX scheduler class\n"
131 "\tsched-queue <port> <queue> <class> bind NIC queues to TX Scheduling class\n"
132 "\tstdio interactive mode\n"
147 real_doit(unsigned long cmd, void *data, const char *cmdstr)
159 str_to_number(const char *s, long *val, long long *vall)
203 register_io(int argc, const char *argv[], int size)
265 return (val >> shift) & ((1 << len) - 1);
269 dump_block_regs(const struct reg_info *reg_array, const uint32_t *regs)
273 for ( ; reg_array->name; ++reg_array)
274 if (!reg_array->len) {
275 reg_val = regs[reg_array->addr / 4];
276 printf("[%#7x] %-47s %#-10x %u\n", reg_array->addr,
277 reg_array->name, reg_val, reg_val);
279 uint32_t v = xtract(reg_val, reg_array->addr,
280 reg_array->len);
282 printf(" %*u:%u %-47s %#-10x %u\n",
283 reg_array->addr < 10 ? 3 : 2,
284 reg_array->addr + reg_array->len - 1,
285 reg_array->addr, reg_array->name, v, v);
292 dump_regs_table(int argc, const char *argv[], const uint32_t *regs,
293 const struct mod_regs *modtab, int nmodules)
306 for ( ; nmodules; nmodules--, modtab++)
307 fprintf(stderr, " %s", modtab->name);
313 for ( ; nmodules; nmodules--, modtab++) {
317 if (!strcmp(argv[i], modtab->name))
322 dump_block_regs(modtab->ri, regs);
330 dump_regs_t4(int argc, const char *argv[], const uint32_t *regs)
366 dump_regs_t5(int argc, const char *argv[], const uint32_t *regs)
404 dump_regs_t6(int argc, const char *argv[], const uint32_t *regs)
441 dump_regs_t7(int argc, const char *argv[], const uint32_t *regs)
482 dump_regs_t4vf(int argc, const char *argv[], const uint32_t *regs)
496 dump_regs_t5vf(int argc, const char *argv[], const uint32_t *regs)
510 dump_regs_t6vf(int argc, const char *argv[], const uint32_t *regs)
524 dump_regs_t7vf(int argc, const char *argv[], const uint32_t *regs)
538 dump_regs(int argc, const char *argv[])
590 do_show_info_header(uint32_t mode)
596 switch (mode & i) {
604 if (mode & T4_FILTER_IC_VNIC)
640 * Parse an argument sub-vector as a { <parameter name> <value>[:<mask>] }
641 * ordered tuple. If the parameter name in the argument sub-vector does not
652 parse_val_mask(const char *param, const char *args[], uint32_t *val,
692 * Parse an argument sub-vector as a { <parameter name> <addr>[/<mask>] }
693 * ordered tuple. If the parameter name in the argument sub-vector does not
701 * family -- IPv4 or IPv6 -- of the address[/mask] and return its actual
714 parse_ipaddr(const char *param, const char *args[], int *afp, uint8_t addr[],
717 const char *colon, *afn;
798 for (m = mask; masksize >= 8; m++, masksize -= 8)
801 *m = ~0 << (8 - masksize);
808 * Parse an argument sub-vector as a { <parameter name> <value> } ordered
809 * tuple. If the parameter name in the argument sub-vector does not match the
815 parse_val(const char *param, const char *args[], uint32_t *val)
853 do_show_one_filter_info(struct t4_filter *t, uint32_t mode)
857 printf("%4d", t->idx);
858 if (t->hits == UINT64_MAX)
859 printf(" %8s", "-");
861 printf(" %8ju", t->hits);
867 switch (mode & i) {
869 printf(" %1d/%1d", t->fs.val.fcoe, t->fs.mask.fcoe);
872 printf(" %1d/%1d", t->fs.val.iport, t->fs.mask.iport);
875 if (mode & T4_FILTER_IC_VNIC) {
877 t->fs.val.pfvf_vld,
878 (t->fs.val.vnic >> 13) & 0x7,
879 t->fs.val.vnic & 0x1fff,
880 t->fs.mask.pfvf_vld,
881 (t->fs.mask.vnic >> 13) & 0x7,
882 t->fs.mask.vnic & 0x1fff);
885 t->fs.val.ovlan_vld, t->fs.val.vnic,
886 t->fs.mask.ovlan_vld, t->fs.mask.vnic);
891 t->fs.val.vlan_vld, t->fs.val.vlan,
892 t->fs.mask.vlan_vld, t->fs.mask.vlan);
895 printf(" %02x/%02x", t->fs.val.tos, t->fs.mask.tos);
898 printf(" %02x/%02x", t->fs.val.proto, t->fs.mask.proto);
901 printf(" %04x/%04x", t->fs.val.ethtype,
902 t->fs.mask.ethtype);
905 printf(" %03x/%03x", t->fs.val.macidx,
906 t->fs.mask.macidx);
909 printf(" %1x/%1x", t->fs.val.matchtype,
910 t->fs.mask.matchtype);
913 printf(" %1d/%1d", t->fs.val.frag, t->fs.mask.frag);
924 filters_show_ipaddr(t->fs.type, t->fs.val.dip, t->fs.mask.dip);
925 filters_show_ipaddr(t->fs.type, t->fs.val.sip, t->fs.mask.sip);
927 t->fs.val.dport, t->fs.mask.dport,
928 t->fs.val.sport, t->fs.mask.sport);
933 if (t->fs.action == FILTER_DROP)
935 else if (t->fs.action == FILTER_SWITCH) {
936 printf(" Switch: port=%d", t->fs.eport);
937 if (t->fs.newdmac)
941 t->fs.dmac[0], t->fs.dmac[1],
942 t->fs.dmac[2], t->fs.dmac[3],
943 t->fs.dmac[4], t->fs.dmac[5],
944 t->l2tidx);
945 if (t->fs.newsmac)
949 t->fs.smac[0], t->fs.smac[1],
950 t->fs.smac[2], t->fs.smac[3],
951 t->fs.smac[4], t->fs.smac[5],
952 t->smtidx);
953 if (t->fs.newvlan == VLAN_REMOVE)
955 else if (t->fs.newvlan == VLAN_INSERT)
956 printf(", vlan=insert(%x)", t->fs.vlan);
957 else if (t->fs.newvlan == VLAN_REWRITE)
958 printf(", vlan=rewrite(%x)", t->fs.vlan);
961 if (t->fs.dirsteer == 0) {
963 if (t->fs.maskhash)
964 printf("(region %d)", t->fs.iq << 1);
966 printf("%d", t->fs.iq);
967 if (t->fs.dirsteerhash == 0)
973 if (g.chip_id <= 5 && t->fs.prio)
975 if (t->fs.rpttid)
983 uint32_t mode = 0, header, hpfilter = 0;
987 /* Get the global filter mode first */
988 rc = doit(CHELSIO_T4_GET_FILTER_MODE, &mode);
1005 do_show_info_header(mode);
1009 do_show_one_filter_info(&t, mode);
1025 do_show_info_header(mode);
1028 do_show_one_filter_info(&t, mode);
1037 uint32_t mode = hashfilter;
1040 rc = doit(CHELSIO_T4_GET_FILTER_MODE, &mode);
1044 if (mode & T4_FILTER_IPv4)
1046 if (mode & T4_FILTER_IPv6)
1048 if (mode & T4_FILTER_IP_SADDR)
1050 if (mode & T4_FILTER_IP_DADDR)
1052 if (mode & T4_FILTER_IP_SPORT)
1054 if (mode & T4_FILTER_IP_DPORT)
1056 if (mode & T4_FILTER_IP_FRAGMENT)
1058 if (mode & T4_FILTER_MPS_HIT_TYPE)
1060 if (mode & T4_FILTER_MAC_IDX)
1062 if (mode & T4_FILTER_ETH_TYPE)
1064 if (mode & T4_FILTER_IP_PROTO)
1066 if (mode & T4_FILTER_IP_TOS)
1068 if (mode & T4_FILTER_VLAN)
1070 if (mode & T4_FILTER_VNIC) {
1071 if (mode & T4_FILTER_IC_VNIC)
1073 else if (mode & T4_FILTER_IC_ENCAP)
1078 if (mode & T4_FILTER_PORT)
1080 if (mode & T4_FILTER_FCoE)
1088 set_filter_mode(int argc, const char *argv[], int hashfilter)
1090 uint32_t mode = 0;
1093 for (; argc; argc--, argv++) {
1100 mode |= T4_FILTER_IP_FRAGMENT;
1102 mode |= T4_FILTER_MPS_HIT_TYPE;
1104 mode |= T4_FILTER_MAC_IDX;
1106 mode |= T4_FILTER_ETH_TYPE;
1108 mode |= T4_FILTER_IP_PROTO;
1110 mode |= T4_FILTER_IP_TOS;
1112 mode |= T4_FILTER_VLAN;
1114 mode |= T4_FILTER_VNIC;
1117 mode |= T4_FILTER_VNIC;
1118 mode |= T4_FILTER_IC_VNIC;
1123 mode |= T4_FILTER_VNIC;
1124 mode |= T4_FILTER_IC_ENCAP;
1129 mode |= T4_FILTER_PORT;
1131 mode |= T4_FILTER_FCoE;
1133 warnx("\"%s\" is not valid while setting filter mode.",
1148 return doit(CHELSIO_T4_SET_FILTER_MASK, &mode);
1150 return doit(CHELSIO_T4_SET_FILTER_MODE, &mode);
1168 set_filter(uint32_t idx, int argc, const char *argv[], int hash)
1183 const char **args = &argv[start_arg];
1321 else if (!strcmp(argv[start_arg + 1], "dip-dp"))
1323 else if (!strcmp(argv[start_arg + 1], "dip-dp-sip"))
1325 else if (!strcmp(argv[start_arg + 1], "dip-dp-sp"))
1327 else if (!strcmp(argv[start_arg + 1], "sip-sp"))
1329 else if (!strcmp(argv[start_arg + 1], "dip-sip-sp"))
1335 "dip-dp, dip-dp-sip, dip-dp-sp, sip-sp, "
1336 "dip-sip-sp, and all", argv[start_arg + 1]);
1412 warnx("nat params only make sense with valid nat mode");
1434 filter_cmd(int argc, const char *argv[], int hashfilter)
1453 /* mode */
1454 if (argc == 1 && strcmp(argv[0], "mode") == 0)
1457 /* mode <mode> */
1458 if (strcmp(argv[0], "mode") == 0)
1459 return set_filter_mode(argc - 1, argv + 1, hashfilter);
1470 idx = (uint32_t) -1;
1509 argc--;
1518 * Shows the fields of a multi-word structure. The structure is considered to
1519 * consist of @nwords 32-bit words (i.e, it's an (@nwords * 32)-bit structure)
1520 * whose fields are described by @fd. The 32-bit words are given in @words
1521 * starting with the least significant 32-bit word.
1524 show_struct(const uint32_t *words, int nwords, const struct field_desc *fd)
1527 const struct field_desc *p;
1529 for (p = fd; p->name; p++)
1530 w = max(w, strlen(p->name));
1532 while (fd->name) {
1534 int first_word = fd->start / 32;
1535 int shift = fd->start % 32;
1536 int width = fd->end - fd->start + 1;
1537 unsigned long long mask = (1ULL << width) - 1;
1540 ((uint64_t)words[first_word + 1] << (32 - shift));
1542 data |= ((uint64_t)words[first_word + 2] << (64 - shift));
1544 if (fd->islog2)
1546 printf("%-*s ", w, fd->name);
1547 printf(fd->hex ? "%#llx\n" : "%llu\n", data << fd->shift);
1556 show_t7_ctxt(const struct t4_sge_ctxt *p)
1718 if (p->mem_id == SGE_CONTEXT_EGRESS)
1719 show_struct(p->data, 7, (p->data[0] & 2) ? fl_t7 : egress_t7);
1720 else if (p->mem_id == SGE_CONTEXT_FLM)
1721 show_struct(p->data, 5, flm_t7);
1722 else if (p->mem_id == SGE_CONTEXT_INGRESS)
1723 show_struct(p->data, 6, ingress_t7);
1724 else if (p->mem_id == SGE_CONTEXT_CNM)
1725 show_struct(p->data, 2, conm_t7);
1729 show_t5t6_ctxt(const struct t4_sge_ctxt *p, int vers)
1964 if (p->mem_id == SGE_CONTEXT_EGRESS) {
1965 if (p->data[0] & 2)
1966 show_struct(p->data, 6, fl_t5);
1968 show_struct(p->data, 6, egress_t5);
1970 show_struct(p->data, 6, egress_t6);
1971 } else if (p->mem_id == SGE_CONTEXT_FLM)
1972 show_struct(p->data, 3, vers == 5 ? flm_t5 : flm_t6);
1973 else if (p->mem_id == SGE_CONTEXT_INGRESS)
1974 show_struct(p->data, 5, vers == 5 ? ingress_t5 : ingress_t6);
1975 else if (p->mem_id == SGE_CONTEXT_CNM)
1976 show_struct(p->data, 1, conm_t5);
1980 show_t4_ctxt(const struct t4_sge_ctxt *p)
2105 if (p->mem_id == SGE_CONTEXT_EGRESS)
2106 show_struct(p->data, 6, (p->data[0] & 2) ? fl_t4 : egress_t4);
2107 else if (p->mem_id == SGE_CONTEXT_FLM)
2108 show_struct(p->data, 3, flm_t4);
2109 else if (p->mem_id == SGE_CONTEXT_INGRESS)
2110 show_struct(p->data, 5, ingress_t4);
2111 else if (p->mem_id == SGE_CONTEXT_CNM)
2112 show_struct(p->data, 1, conm_t4);
2119 get_sge_context(int argc, const char *argv[])
2172 loadfw(int argc, const char *argv[])
2176 const char *fname = argv[0];
2211 loadcfg(int argc, const char *argv[])
2215 const char *fname = argv[0];
2254 dumpstate(int argc, const char *argv[])
2258 const char *fname = argv[0];
2318 loadboot(int argc, const char *argv[])
2324 const char *fname = argv[0];
2377 loadbootcfg(int argc, const char *argv[])
2381 const char *fname = argv[0];
2419 * Display memory as list of 'n' 4-byte values per line.
2424 const char *s;
2428 for (i = 0; len && i < n; i++, buf++, len -= 4) {
2437 memdump(int argc, const char *argv[])
2466 * Display TCB as list of 'n' 4-byte values per line.
2472 const char *s;
2476 for (i = 0; len && i < n; i++, buf++, len -= 4) {
2491 read_tcb(int argc, const char *argv[])
2522 read_i2c(int argc, const char *argv[])
2576 clearstats(int argc, const char *argv[])
2622 port_idx = t.tp.port - 4;
2625 port_idx = t.tp.port - 8;
2628 port_idx = t.tp.port - 12;
2631 port_idx = t.tp.port - 16;
2699 * matching). Right now this is a quick-n-dirty implementation that traces the
2703 set_tracer(uint8_t idx, int argc, const char *argv[])
2725 port = argv[0][2] - '0';
2732 port = argv[0][2] - '0';
2739 port = argv[0][2] - '0';
2761 tracer_cmd(int argc, const char *argv[])
2798 return set_tracer(idx, argc - 1, argv + 1);
2837 modinfo(int argc, const char *argv[])
2889 string[i - SFF_8472_VENDOR_START] = i2cd.data[0];
2898 string[i - SFF_8472_SN_START] = i2cd.data[0];
2907 string[i - SFF_8472_PN_START] = i2cd.data[0];
2916 string[i - SFF_8472_REV_START] = i2cd.data[0];
2937 printf("-");
2981 get_sched_param(const char *param, const char *args[], long *val)
2999 sched_class(int argc, const char *argv[])
3001 struct t4_sched_params op;
3004 memset(&op, 0xff, sizeof(op));
3005 op.subcmd = -1;
3006 op.type = -1;
3008 warnx("missing scheduling sub-command");
3012 op.subcmd = SCHED_CLASS_SUBCMD_CONFIG;
3013 op.u.config.minmax = -1;
3015 op.subcmd = SCHED_CLASS_SUBCMD_PARAMS;
3016 op.u.params.level = op.u.params.mode = op.u.params.rateunit =
3017 op.u.params.ratemode = op.u.params.channel =
3018 op.u.params.cl = op.u.params.minrate = op.u.params.maxrate =
3019 op.u.params.weight = op.u.params.pktsize = -1;
3021 warnx("invalid scheduling sub-command \"%s\"", argv[0]);
3028 const char **args = &argv[i];
3039 op.type = SCHED_CLASS_TYPE_PACKET;
3048 if (op.subcmd == SCHED_CLASS_SUBCMD_CONFIG) {
3050 op.u.config.minmax = (int8_t)l;
3061 if (op.subcmd != SCHED_CLASS_SUBCMD_PARAMS)
3065 if (!strcmp(args[1], "cl-rl"))
3066 op.u.params.level = SCHED_CLASS_LEVEL_CL_RL;
3067 else if (!strcmp(args[1], "cl-wrr"))
3068 op.u.params.level = SCHED_CLASS_LEVEL_CL_WRR;
3069 else if (!strcmp(args[1], "ch-rl"))
3070 op.u.params.level = SCHED_CLASS_LEVEL_CH_RL;
3076 } else if (!strcmp(args[0], "mode")) {
3078 op.u.params.mode = SCHED_CLASS_MODE_CLASS;
3080 op.u.params.mode = SCHED_CLASS_MODE_FLOW;
3082 warnx("invalid mode parameter \"%s\"", args[1]);
3085 } else if (!strcmp(args[0], "rate-unit")) {
3087 op.u.params.rateunit = SCHED_CLASS_RATEUNIT_BITS;
3089 op.u.params.rateunit = SCHED_CLASS_RATEUNIT_PKTS;
3091 warnx("invalid rate-unit parameter \"%s\"",
3095 } else if (!strcmp(args[0], "rate-mode")) {
3097 op.u.params.ratemode = SCHED_CLASS_RATEMODE_REL;
3099 op.u.params.ratemode = SCHED_CLASS_RATEMODE_ABS;
3101 warnx("invalid rate-mode parameter \"%s\"",
3106 op.u.params.channel = (int8_t)l;
3108 op.u.params.cl = (int8_t)l;
3109 else if (!get_sched_param("min-rate", args, &l))
3110 op.u.params.minrate = (int32_t)l;
3111 else if (!get_sched_param("max-rate", args, &l))
3112 op.u.params.maxrate = (int32_t)l;
3114 op.u.params.weight = (int16_t)l;
3115 else if (!get_sched_param("pkt-size", args, &l))
3116 op.u.params.pktsize = (int16_t)l;
3130 if (op.type < 0) {
3134 if (op.subcmd == SCHED_CLASS_SUBCMD_CONFIG) {
3135 if (op.u.config.minmax < 0) {
3140 if (op.subcmd == SCHED_CLASS_SUBCMD_PARAMS) {
3141 if (op.u.params.level < 0) {
3145 if (op.u.params.mode < 0 &&
3146 op.u.params.level == SCHED_CLASS_LEVEL_CL_RL) {
3147 warnx("sched params \"mode\" parameter missing");
3150 if (op.u.params.rateunit < 0 &&
3151 (op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
3152 op.u.params.level == SCHED_CLASS_LEVEL_CH_RL)) {
3153 warnx("sched params \"rate-unit\" parameter missing");
3156 if (op.u.params.ratemode < 0 &&
3157 (op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
3158 op.u.params.level == SCHED_CLASS_LEVEL_CH_RL)) {
3159 warnx("sched params \"rate-mode\" parameter missing");
3162 if (op.u.params.channel < 0) {
3166 if (op.u.params.cl < 0 &&
3167 (op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
3168 op.u.params.level == SCHED_CLASS_LEVEL_CL_WRR)) {
3172 if (op.u.params.maxrate < 0 &&
3173 (op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
3174 op.u.params.level == SCHED_CLASS_LEVEL_CH_RL)) {
3175 warnx("sched params \"max-rate\" missing for "
3176 "rate-limit level");
3179 if (op.u.params.level == SCHED_CLASS_LEVEL_CL_WRR &&
3180 (op.u.params.weight < 1 || op.u.params.weight > 99)) {
3182 "(not 1-99) for weighted-round-robin level");
3185 if (op.u.params.pktsize < 0 &&
3186 op.u.params.level == SCHED_CLASS_LEVEL_CL_RL) {
3187 warnx("sched params \"pkt-size\" missing for "
3188 "rate-limit level");
3191 if (op.u.params.mode == SCHED_CLASS_MODE_FLOW &&
3192 op.u.params.ratemode != SCHED_CLASS_RATEMODE_ABS) {
3193 warnx("sched params mode flow needs rate-mode absolute");
3196 if (op.u.params.ratemode == SCHED_CLASS_RATEMODE_REL &&
3197 !in_range(op.u.params.maxrate, 1, 100)) {
3198 warnx("sched params \"max-rate\" takes "
3199 "percentage value(1-100) for rate-mode relative");
3202 if (op.u.params.ratemode == SCHED_CLASS_RATEMODE_ABS &&
3203 !in_range(op.u.params.maxrate, 1, 100000000)) {
3204 warnx("sched params \"max-rate\" takes "
3205 "value(1-100000000) for rate-mode absolute");
3208 if (op.u.params.maxrate > 0 &&
3209 op.u.params.maxrate < op.u.params.minrate) {
3210 warnx("sched params \"max-rate\" is less than "
3211 "\"min-rate\"");
3217 warnx("%d error%s in sched-class command", errs,
3222 return doit(CHELSIO_T4_SCHED_CLASS, &op);
3226 sched_queue(int argc, const char *argv[])
3228 struct t4_sched_queue op = {0};
3243 op.port = (uint8_t)val;
3246 op.queue = -1;
3249 if (*p || val < -1) {
3253 op.queue = (int8_t)val;
3257 op.cl = -1;
3260 if (*p || val < -1) {
3264 op.cl = (int8_t)val;
3267 return doit(CHELSIO_T4_SCHED_QUEUE, &op);
3271 parse_offload_settings_word(const char *s, char **pnext, const char *ws,
3286 os->offload = (*pneg + 1) & 1;
3289 os->rx_coalesce = (*pneg + 1) & 1;
3292 os->tstamp = (*pneg + 1) & 1;
3295 os->sack = (*pneg + 1) & 1;
3298 os->nagle = (*pneg + 1) & 1;
3301 os->ecn = (*pneg + 1) & 1;
3304 os->ddp = (*pneg + 1) & 1;
3307 os->tls = (*pneg + 1) & 1;
3333 os->cong_algo = 0;
3335 os->cong_algo = 1;
3337 os->cong_algo = 2;
3339 os->cong_algo = 3;
3345 val = -1;
3347 /* (nsched_cls - 1) is spelled 15 here. */
3354 os->sched_class = val;
3372 os->txq = val;
3373 os->rxq = val;
3375 os->txq = val;
3377 os->rxq = val;
3382 val = -1;
3390 os->mss = val;
3401 parse_offload_settings(const char *settings_ro, struct offload_settings *os)
3403 const char *ws = " \f\n\r\v\t";
3406 static const struct offload_settings default_settings = {
3408 .rx_coalesce = -1,
3409 .cong_algo = -1,
3410 .sched_class = -1,
3411 .tstamp = -1,
3412 .sack = -1,
3413 .nagle = -1,
3414 .ecn = -1,
3415 .ddp = -1,
3416 .tls = -1,
3419 .mss = -1,
3463 llen--;
3479 /* check for special strings: "-", "all", "any" */
3480 if (*str == '-') {
3496 * A rule has 3 parts: an open-type, a match expression, and offload settings.
3498 * [<open-type>] <expr> => <settings>
3512 s = &line[llen - 1];
3514 *s-- = '\0';
3515 llen--;
3530 r->open_type = *line;
3533 warnx("invalid socket-type \"%c\" on line %zd.", *line, lno);
3539 r->open_type, lno);
3560 * <expr> is either a special name (all, any) or a pcap-filter(7).
3561 * In case of a special name the bpf_prog stays all-zero.
3564 if (pcap_compile(pd, &r->bpf_prog, expr, 1,
3573 if (parse_offload_settings(settings, &r->settings) != 0) {
3576 pcap_freecode(&r->bpf_prog);
3585 * Note that op itself is not dynamically allocated.
3588 free_offload_policy(struct t4_offload_policy *op)
3592 for (i = 0; i < op->nrules; i++) {
3595 * for an rule that matches on 'any/all/-'.
3597 pcap_freecode(&op->rule[i].bpf_prog);
3599 free(op->rule);
3600 op->nrules = 0;
3601 op->rule = NULL;
3607 * Fills up op->nrules and op->rule.
3610 parse_offload_policy(const char *fname, struct t4_offload_policy *op)
3635 op->nrules = 0;
3636 op->rule = NULL;
3639 while ((llen = getline(&line, &lcap, fp)) != -1) {
3646 if (op->nrules == maxrules) {
3648 r = realloc(op->rule,
3656 op->rule = r;
3659 r = &op->rule[op->nrules];
3666 op->nrules++;
3677 if (op->nrules == 0) {
3685 free_offload_policy(op);
3692 load_offload_policy(int argc, const char *argv[])
3695 const char *fname = argv[0];
3696 struct t4_offload_policy op = {0};
3704 /* op.nrules is 0 and that means clear policy */
3705 return (doit(CHELSIO_T4_SET_OFLD_POLICY, &op));
3708 rc = parse_offload_policy(fname, &op);
3714 rc = doit(CHELSIO_T4_SET_OFLD_POLICY, &op);
3715 free_offload_policy(&op);
3747 clip_cmd(int argc, const char *argv[])
3784 run_cmd(int argc, const char *argv[])
3786 int rc = -1;
3787 const char *cmd = argv[0];
3790 argc--;
3817 else if (!strcmp(cmd, "sched-class"))
3819 else if (!strcmp(cmd, "sched-queue"))
3825 else if (!strcmp(cmd, "loadboot-cfg"))
3849 const char *args[MAX_ARGS + 1];
3894 open_nexus_device(const char *s)
3896 const int len = strlen(s);
3898 const char *num;
3903 if (len < 2 || isdigit(s[0]) || !isdigit(s[len - 1]))
3905 for (num = s + len - 1; isdigit(*num); num--)
3942 main(int argc, const char *argv[])
3944 int rc = -1;
3949 if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
3963 argc -= 2;