From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C87EAC169C4 for ; Wed, 6 Feb 2019 12:43:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8ABFA20B1F for ; Wed, 6 Feb 2019 12:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728508AbfBFMnK (ORCPT ); Wed, 6 Feb 2019 07:43:10 -0500 Received: from mx2.suse.de ([195.135.220.15]:56288 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726598AbfBFMnK (ORCPT ); Wed, 6 Feb 2019 07:43:10 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 42194AD25; Wed, 6 Feb 2019 12:43:09 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id CDCD6E0142; Wed, 6 Feb 2019 13:43:07 +0100 (CET) Date: Wed, 6 Feb 2019 13:43:07 +0100 From: Michal Kubecek To: netdev@vger.kernel.org Cc: Jeff Kirsher , linville@tuxdriver.com, Nicholas Nunley , nhorman@redhat.com, sassmann@redhat.com Subject: Re: [PATCH v2 3/6] ethtool: introduce new ioctl for per-queue settings Message-ID: <20190206124307.GA18410@unicorn.suse.cz> References: <20190206000106.24364-1-jeffrey.t.kirsher@intel.com> <20190206000106.24364-3-jeffrey.t.kirsher@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190206000106.24364-3-jeffrey.t.kirsher@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Feb 05, 2019 at 04:01:03PM -0800, Jeff Kirsher wrote: > +static int do_perqueue(struct cmd_context *ctx) > +{ > + __u32 queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)] = {0}; > + int i, n_queues = 0; > + > + if (ctx->argc == 0) > + exit_bad_args(); > + > + /* > + * The sub commands will be applied to > + * all queues if no queue_mask set > + */ > + if (strncmp(*ctx->argp, "queue_mask", 10)) { This would match any string starting with "queue_mask", is it intended? > + n_queues = find_max_num_queues(ctx); > + if (n_queues < 0) { > + perror("Cannot get number of queues"); > + return -EFAULT; > + } > + for (i = 0; i < n_queues / 32; i++) > + queue_mask[i] = ~0; > + queue_mask[i] = (1 << (n_queues - i * 32)) - 1; It's unlikely today, I guess, but in theory, this would overflow if n_queues == MAX_NUM_QUEUE > + fprintf(stdout, > + "The sub commands will be applied to all %d queues\n", > + n_queues); > + } else { > + ctx->argc--; > + ctx->argp++; > + n_queues = set_queue_mask(queue_mask, *ctx->argp); > + if (n_queues < 0) { > + perror("Invalid queue mask"); > + return n_queues; > + } > + ctx->argc--; > + ctx->argp++; > + } > + > + i = find_option(ctx->argc, ctx->argp); > + if (i < 0) > + exit_bad_args(); > + > + /* no sub_command support yet */ > + > + return 0; > +} Michal Kubecek