aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_backend.c
diff options
context:
space:
mode:
authorMarcelo Araujo <araujo@FreeBSD.org>2018-05-10 03:50:20 +0000
committerMarcelo Araujo <araujo@FreeBSD.org>2018-05-10 03:50:20 +0000
commit8951f05525ee4e9a93cc568dccd154405aae7419 (patch)
tree503e8ca76afeb0231224fd5f2522663ca24ca5f6 /sys/cam/ctl/ctl_backend.c
parent3429b518c9bfbce5a16d76949d75a843567ba2de (diff)
downloadsrc-8951f05525ee4e9a93cc568dccd154405aae7419.tar.gz
src-8951f05525ee4e9a93cc568dccd154405aae7419.zip
Rework CTL frontend & backend options to use nv(3), allow creating multiple
ioctl frontend ports. This revision introduces two changes to CTL: - Changes the way options are passed to CTL_LUN_REQ and CTL_PORT_REQ ioctls. Removes ctl_be_arg structure and associated logic and replaces it with nv(3)-based logic for passing in and out arguments. - Allows creating multiple ioctl frontend ports using either ctladm(8) or ctld(8). New frontend ports are represented by /dev/cam/ctl<pp>.<vp> nodes, eg /dev/cam/ctl5.3. Those device nodes respond only to CTL_IO ioctl. New command-line options for ctladm: # creates new ioctl frontend port with using free pp and vp=0 ctladm port -c # creates new ioctl frontend port with pp=10 and vp=0 ctladm port -c -O pp=10 # creates new ioctl frontend port with pp=11 and vp=12 ctladm port -c -O pp=11 -O vp=12 # removes port with number 4 (it's a "targ_port" number, not pp number) ctladm port -r -p 4 New syntax for ctl.conf: target ... { port ioctl/<pp> ... } target ... { port ioctl/<pp>/<vp> ... Note: Most of this work was made by jceel@, thank you. Submitted by: jceel Reworked by: myself Reviewed by: mav (earlier versions and recently during the rework) Obtained from: FreeNAS and TrueOS Relnotes: Yes Sponsored by: iXsystems Inc. Differential Revision: https://reviews.freebsd.org/D9299
Notes
Notes: svn path=/head/; revision=333446
Diffstat (limited to 'sys/cam/ctl/ctl_backend.c')
-rw-r--r--sys/cam/ctl/ctl_backend.c90
1 files changed, 0 insertions, 90 deletions
diff --git a/sys/cam/ctl/ctl_backend.c b/sys/cam/ctl/ctl_backend.c
index 9918ce404d58..0a0645556636 100644
--- a/sys/cam/ctl/ctl_backend.c
+++ b/sys/cam/ctl/ctl_backend.c
@@ -141,93 +141,3 @@ ctl_backend_find(char *backend_name)
return (NULL);
}
-void
-ctl_init_opts(ctl_options_t *opts, int num_args, struct ctl_be_arg *args)
-{
- struct ctl_option *opt;
- int i;
-
- STAILQ_INIT(opts);
- for (i = 0; i < num_args; i++) {
- if ((args[i].flags & CTL_BEARG_RD) == 0)
- continue;
- if ((args[i].flags & CTL_BEARG_ASCII) == 0)
- continue;
- opt = malloc(sizeof(*opt), M_CTL, M_WAITOK);
- opt->name = strdup(args[i].kname, M_CTL);
- opt->value = strdup(args[i].kvalue, M_CTL);
- STAILQ_INSERT_TAIL(opts, opt, links);
- }
-}
-
-void
-ctl_update_opts(ctl_options_t *opts, int num_args, struct ctl_be_arg *args)
-{
- struct ctl_option *opt;
- int i;
-
- for (i = 0; i < num_args; i++) {
- if ((args[i].flags & CTL_BEARG_RD) == 0)
- continue;
- if ((args[i].flags & CTL_BEARG_ASCII) == 0)
- continue;
- STAILQ_FOREACH(opt, opts, links) {
- if (strcmp(opt->name, args[i].kname) == 0)
- break;
- }
- if (args[i].kvalue != NULL &&
- ((char *)args[i].kvalue)[0] != 0) {
- if (opt) {
- free(opt->value, M_CTL);
- opt->value = strdup(args[i].kvalue, M_CTL);
- } else {
- opt = malloc(sizeof(*opt), M_CTL, M_WAITOK);
- opt->name = strdup(args[i].kname, M_CTL);
- opt->value = strdup(args[i].kvalue, M_CTL);
- STAILQ_INSERT_TAIL(opts, opt, links);
- }
- } else if (opt) {
- STAILQ_REMOVE(opts, opt, ctl_option, links);
- free(opt->name, M_CTL);
- free(opt->value, M_CTL);
- free(opt, M_CTL);
- }
- }
-}
-
-void
-ctl_free_opts(ctl_options_t *opts)
-{
- struct ctl_option *opt;
-
- while ((opt = STAILQ_FIRST(opts)) != NULL) {
- STAILQ_REMOVE_HEAD(opts, links);
- free(opt->name, M_CTL);
- free(opt->value, M_CTL);
- free(opt, M_CTL);
- }
-}
-
-char *
-ctl_get_opt(ctl_options_t *opts, const char *name)
-{
- struct ctl_option *opt;
-
- STAILQ_FOREACH(opt, opts, links) {
- if (strcmp(opt->name, name) == 0) {
- return (opt->value);
- }
- }
- return (NULL);
-}
-
-int
-ctl_get_opt_number(ctl_options_t *opts, const char *name, uint64_t *val)
-{
- const char *value;
-
- value = ctl_get_opt(opts, name);
- if (value == NULL)
- return (-2);
- return (ctl_expand_number(value, val));
-}