aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_options.c
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@redhat.com>2014-01-22 08:53:36 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-22 18:38:44 -0500
commit24089ba1026a684d64bc0eeb6af634e26c9501c4 (patch)
tree6e9f4c0539262c56e6f0fb2b0e17a5e01a9e1090 /drivers/net/bonding/bond_options.c
parentd1fbd3ed9366904b58b1c0c30b22d51dc793de99 (diff)
bonding: convert queue_id to use the new option API
This patch adds the necessary changes so queue_id would use the new bonding option API. Also move it to its own set function in bond_options.c and fix some style errors. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_options.c')
-rw-r--r--drivers/net/bonding/bond_options.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 2315104de8c0..8775c724c700 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -254,6 +254,13 @@ static struct bond_option bond_opts[] = {
254 BIT(BOND_MODE_ALB)), 254 BIT(BOND_MODE_ALB)),
255 .set = bond_option_active_slave_set 255 .set = bond_option_active_slave_set
256 }, 256 },
257 [BOND_OPT_QUEUE_ID] = {
258 .id = BOND_OPT_QUEUE_ID,
259 .name = "queue_id",
260 .desc = "Set queue id of a slave",
261 .flags = BOND_OPTFLAG_RAWVAL,
262 .set = bond_option_queue_id_set
263 },
257 { } 264 { }
258}; 265};
259 266
@@ -1130,3 +1137,66 @@ int bond_option_ad_select_set(struct bonding *bond,
1130 1137
1131 return 0; 1138 return 0;
1132} 1139}
1140
1141int bond_option_queue_id_set(struct bonding *bond,
1142 struct bond_opt_value *newval)
1143{
1144 struct slave *slave, *update_slave;
1145 struct net_device *sdev;
1146 struct list_head *iter;
1147 char *delim;
1148 int ret = 0;
1149 u16 qid;
1150
1151 /* delim will point to queue id if successful */
1152 delim = strchr(newval->string, ':');
1153 if (!delim)
1154 goto err_no_cmd;
1155
1156 /* Terminate string that points to device name and bump it
1157 * up one, so we can read the queue id there.
1158 */
1159 *delim = '\0';
1160 if (sscanf(++delim, "%hd\n", &qid) != 1)
1161 goto err_no_cmd;
1162
1163 /* Check buffer length, valid ifname and queue id */
1164 if (strlen(newval->string) > IFNAMSIZ ||
1165 !dev_valid_name(newval->string) ||
1166 qid > bond->dev->real_num_tx_queues)
1167 goto err_no_cmd;
1168
1169 /* Get the pointer to that interface if it exists */
1170 sdev = __dev_get_by_name(dev_net(bond->dev), newval->string);
1171 if (!sdev)
1172 goto err_no_cmd;
1173
1174 /* Search for thes slave and check for duplicate qids */
1175 update_slave = NULL;
1176 bond_for_each_slave(bond, slave, iter) {
1177 if (sdev == slave->dev)
1178 /* We don't need to check the matching
1179 * slave for dups, since we're overwriting it
1180 */
1181 update_slave = slave;
1182 else if (qid && qid == slave->queue_id) {
1183 goto err_no_cmd;
1184 }
1185 }
1186
1187 if (!update_slave)
1188 goto err_no_cmd;
1189
1190 /* Actually set the qids for the slave */
1191 update_slave->queue_id = qid;
1192
1193out:
1194 return ret;
1195
1196err_no_cmd:
1197 pr_info("invalid input for queue_id set for %s.\n",
1198 bond->dev->name);
1199 ret = -EPERM;
1200 goto out;
1201
1202}