| 84 | } |
| 85 | |
| 86 | int main(int argc, char **argv) |
| 87 | { |
| 88 | int ch, has_action = 0, i; |
| 89 | enum FF_KNICTL_CMD cmd; |
| 90 | struct ff_knictl_args knictl = {.kni_cmd = FF_KNICTL_CMD_GET}; |
| 91 | struct ff_knictl_args pknictl[RTE_MAX_LCORE]; |
| 92 | int proc_id = 0, max_proc_id = -1; |
| 93 | |
| 94 | ff_ipc_init(); |
| 95 | while ((ch = getopt(argc, argv, "hp:P:a:n")) != -1) { |
| 96 | switch(ch) { |
| 97 | case 'p': |
| 98 | proc_id = atoi(optarg); |
| 99 | ff_set_proc_id(proc_id); |
| 100 | break; |
| 101 | case 'P': |
| 102 | max_proc_id = atoi(optarg); |
| 103 | if (max_proc_id < 0 || max_proc_id >= RTE_MAX_LCORE) { |
| 104 | usage(); |
| 105 | ff_ipc_exit(); |
| 106 | return -1; |
| 107 | } |
| 108 | break; |
| 109 | case 'a': |
| 110 | if (has_action){ |
| 111 | usage(); |
| 112 | ff_ipc_exit(); |
| 113 | return -1; |
| 114 | } |
| 115 | has_action = 1; |
| 116 | cmd = knictl.kni_cmd = FF_KNICTL_CMD_SET; |
| 117 | knictl.kni_action = get_action(optarg); |
| 118 | if (knictl.kni_action < FF_KNICTL_ACTION_DEFAULT || knictl.kni_action >= FF_KNICTL_ACTION_MAX){ |
| 119 | usage(); |
| 120 | ff_ipc_exit(); |
| 121 | return -1; |
| 122 | } |
| 123 | break; |
| 124 | case 'n': |
| 125 | if (has_action){ |
| 126 | usage(); |
| 127 | ff_ipc_exit(); |
| 128 | return -1; |
| 129 | } |
| 130 | has_action = 1; |
| 131 | cmd = knictl.kni_cmd = FF_KNICTL_CMD_GET; |
| 132 | break; |
| 133 | case 'h': |
| 134 | default: |
| 135 | usage(); |
| 136 | ff_ipc_exit(); |
| 137 | return -1; |
| 138 | } |
| 139 | } |
| 140 | if (max_proc_id == -1){ |
| 141 | printf(" using default proc id\n"); |
| 142 | int ret = knictl_status(&knictl); |
| 143 | printf(" %s to %s knictl type: %s\n", ret ? "fail": "success", knictl.kni_cmd == FF_KNICTL_CMD_GET ? "get" : "set", get_action_str(knictl.kni_action)); |
nothing calls this directly
no test coverage detected