From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1FB2AA04BA; Wed, 7 Oct 2020 22:40:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 287971E34; Wed, 7 Oct 2020 22:40:15 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 4889BB62 for ; Wed, 7 Oct 2020 22:40:13 +0200 (CEST) IronPort-SDR: 8m1nDqqQ+lROsvP/8Im5OEh6r0Iq0bmmKHhZFFSJYuM4JaDJW3VOmTPOzuniSpB0SIQ2vVdmvl LVT6qCbmHyMA== X-IronPort-AV: E=McAfee;i="6000,8403,9767"; a="226744253" X-IronPort-AV: E=Sophos;i="5.77,348,1596524400"; d="scan'208";a="226744253" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 13:40:11 -0700 IronPort-SDR: UlgoqRvgwBjt7E2YDw5s/8ew6byCUIVN7BiEDzPU6E+3zxg/NOY2CNQZWKWX24CGH/8CtdVwQH 2R6Wgavfk/9w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,348,1596524400"; d="scan'208";a="297657178" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by fmsmga007.fm.intel.com with ESMTP; 07 Oct 2020 13:40:10 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 7 Oct 2020 13:40:10 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 7 Oct 2020 13:40:10 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (104.47.37.51) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Wed, 7 Oct 2020 13:40:10 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bs6ltHmoatLhCIlY0YDMr4ibd0aWx7mLVO7ohKBn3sKY736lzHT+v8BB5IUZ0uakj69CBwc0908Wvl5uuD+VdCx9VtC/8xVIAuypA/0ir8t2WqIxMQZnFewlIHBQ7ylatyCU/ceRpHLWANgvsaYOkF+ZhzdqXOXv4SWx6NSYBrNY2JK9v1824/EkMOGaCZxWSuMbOd4ZMr4azUKWd72D02HM8H6QoGcrCdGrijIKsabC7G4SvEI+TcdIJgza/LdLbnvJ0ovLdAZKLIXp699tvTjUmi1Xo8ZFQR8rYMMBEInpLZi2Vp9VcqiHfEsVaoKag5eM9VGUIIGky9DMZjqNiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=quR3BG4ZVvPa7v6gIhBDVR+pASxGQ/qMspvdZuPLCV4=; b=noeTzHXVRSXlJohzf91+8PATuNnIieRIXhRv50l0/0yurAgWSWhxLIPZCodBSbFVM4U9jd1Ntk7/WLlBYBGUMJlFEnXJTG4i//ymx+Qr0ePUSXQk9aDchr+Anj9xgZZBXyw+HBuuzQufC1kL/JcimGwtGEFaPLSQamCumX5M9+ZmuCU4m1pymqF34iqKFxwIlFAYOrYCzWZxt5Ylxug7iOACaVj5/VMJtwLt8MQPpwl5ts5iAiEqCWLftlRaY+BS3+rP3G5PjrXL2jIlWaU1+bJuLhwSFGe9G4f196dHHNyDn39fwYSZ/v6hiU6vcEWi4bWTpVxSihsqTxWTdYpqVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=quR3BG4ZVvPa7v6gIhBDVR+pASxGQ/qMspvdZuPLCV4=; b=X4+318HeNoSrTPg6oHIQxo88W3VTiJ3qkaplqEw9M5BkHzfjXgXSSUwMJ3SDQdTmTzTFh+kY7OkxEHvg8YHR5MwlqXYt/uEbeBbY5cx7m8MxLbQ2r8xNFaiuN0SjN1xr+MmKvuyoe35uyr15KgPlRJuDr9fnXENxbz4pqeZ4RwQ= Received: from SN6PR11MB2574.namprd11.prod.outlook.com (2603:10b6:805:59::14) by SA2PR11MB4985.namprd11.prod.outlook.com (2603:10b6:806:111::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.23; Wed, 7 Oct 2020 20:40:09 +0000 Received: from SN6PR11MB2574.namprd11.prod.outlook.com ([fe80::902d:8f85:ea05:a7a]) by SN6PR11MB2574.namprd11.prod.outlook.com ([fe80::902d:8f85:ea05:a7a%4]) with mapi id 15.20.3455.021; Wed, 7 Oct 2020 20:40:09 +0000 From: "Eads, Gage" To: "McDaniel, Timothy" CC: "dev@dpdk.org" , "Carrillo, Erik G" , "Van Haaren, Harry" , "jerinj@marvell.com" Thread-Topic: [PATCH 12/22] event/dlb2: add port link Thread-Index: AQHWiHpgMpY4M3UP7kOY+Y9UK9ctZqmMwbQQ Date: Wed, 7 Oct 2020 20:40:09 +0000 Message-ID: References: <1599855987-25976-1-git-send-email-timothy.mcdaniel@intel.com> <1599855987-25976-13-git-send-email-timothy.mcdaniel@intel.com> In-Reply-To: <1599855987-25976-13-git-send-email-timothy.mcdaniel@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [68.203.30.51] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: badcf41e-2ea2-4624-3f03-08d86b012eb2 x-ms-traffictypediagnostic: SA2PR11MB4985: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:397; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oi0BUkjjeYf59oOEYzYwh/tUSZYaEVgCcqacKFvrW2CgI2r/n14T+YzSR26X+ENuVWwi21xNIHXqb150yx8sjXMLQTGcKJSfSAG9Sq4vJ87PFhi0AJWgT3IQ/cVKELDjmLxxc3RZXT/3vDlR2R+dNZstwbZ0CTxI7y6w/6H25YPTXnhMReKi40g2Ek84hf3yyEa++QK3r9Q7NrvS2tvn1q9yI583NELZ/UFwsc7NkMZQV+h5E5Hk7UUOvPYe5Q1uMxdeXLiEZ37vOqJnDjjvNAhEQf6LKrExFMjnZWTakNe3oVHZsZxwgNR/Xd1QLD8osS+WKdE9cpJ3KdyA8wx8LA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB2574.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39860400002)(376002)(136003)(396003)(5660300002)(4326008)(6636002)(66446008)(55016002)(71200400001)(52536014)(64756008)(66476007)(66946007)(66556008)(76116006)(9686003)(6862004)(33656002)(8676002)(7696005)(316002)(2906002)(6506007)(86362001)(26005)(186003)(478600001)(83380400001)(8936002)(54906003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: 2TkeIKo4ecHS+EikfhxUvTrlgtJmjeefWG8X/2Grq/R+fFgJlzG33rzuPWPHEXsrIN82hJAoVETKKPrTpZTxJlFoXqet4V0+8FlO0aIw0wgqQ1m6BBVTPrMF+aAbfUeiY5pHlYNtULVuiiCORl+E+hRdVY4r+DiOY9T/LNLCLCmqbSu1LRMG8uvR5LNGFGvO4JVP4cmiojzReCG+ZCOSNoNfxUXsuWDBisria+ckU7YXP0tGnG+k4etjSwjEl2CCoh0bNCEAg10Dvb8qwwGNjich7tuvFWI7DcuPw2pw91AS5fogUsNYzZnBaOvCWq/IdzPOX3aZSf2NZHYceEkWHMAtvxWmxa2Ee42YtQy7/cnrtIOa7n1X2b5aXH3Ui/UttmRh/whCTwpq2RukN74iC0/kApS8gcTBY2Gq/jLVcCvh8fhXPQZA3uX3iKXVkEBdCyt0ye2bf3+wo0cFAm85BIptAeLkoyGENcJjHKYUw3FdILazvfur07+ypB9sSqPDTM14gvsXx1lOeY1U/RP/iUCgdwE5hyP6OVH62WbeWWtkJgvZofQvX3zrQC8qcug+gHpzF1xGOF7X0b4Ez1LWVljgAW2VUfX8uHr+Inu7eWqC58Ib2nYihfjWQN7I7YoO1sDCm2xon7nQiclulN6gpg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2574.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: badcf41e-2ea2-4624-3f03-08d86b012eb2 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Oct 2020 20:40:09.4098 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: z5nd+Y9qIDdaHIX6Hd1gepYT7GsfGU4KyipbDi8T0Q1cu9JOH6Q5aB7o8C+2mppKFd6GNNrTl7tGXqf7QB0uyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB4985 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 12/22] event/dlb2: add port link X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > +static int > +dlb2_event_queue_join_ldb(struct dlb2_eventdev *dlb2, > + struct dlb2_eventdev_port *ev_port, > + struct dlb2_eventdev_queue *ev_queue, > + uint8_t priority) > +{ > + int first_avail =3D -1; > + int ret, i; > + > + for (i =3D 0; i < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; i++) { > + if (ev_port->link[i].valid) { > + if (ev_port->link[i].queue_id =3D=3D ev_queue->id && > + ev_port->link[i].priority =3D=3D priority) { > + if (ev_port->link[i].mapped) > + return 0; /* already mapped */ > + first_avail =3D i; > + } > + } else if (first_avail =3D=3D -1) { > + first_avail =3D i; > + } Nit: braces discouraged on a single-statement conditionals > + } > + if (first_avail =3D=3D -1) { > + DLB2_LOG_ERR("dlb2: qm_port %d has no available QID slots.\n", > + ev_port->qm_port.id); > + return -EINVAL; > + } > + > + ret =3D dlb2_hw_map_ldb_qid_to_port(&dlb2->qm_instance, > + ev_port->qm_port.id, > + ev_queue->qm_queue.id, > + priority); > + > + if (!ret) > + ev_port->link[first_avail].mapped =3D true; > + > + return ret; > +} > + > +static int32_t > +dlb2_hw_create_dir_queue(struct dlb2_eventdev *dlb2, > + struct dlb2_eventdev_queue *ev_queue, > + int32_t qm_port_id) > +{ > + struct dlb2_hw_dev *handle =3D &dlb2->qm_instance; > + struct dlb2_create_dir_queue_args cfg; > + int32_t ret; > + > + /* The directed port is always configured before its queue */ > + cfg.port_id =3D qm_port_id; > + > + if (ev_queue->depth_threshold =3D=3D 0) { > + cfg.depth_threshold =3D > RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH; > + ev_queue->depth_threshold =3D > RTE_PMD_DLB2_DEFAULT_DEPTH_THRESH; > + } else { > + cfg.depth_threshold =3D ev_queue->depth_threshold; > + } Nit: braces discouraged on a single-statement conditionals > + > + ret =3D dlb2_iface_dir_queue_create(handle, &cfg); > + if (ret < 0) { > + DLB2_LOG_ERR("dlb2: create DIR event queue error, ret=3D%d > (driver status: %s)\n", > + ret, dlb2_error_strings[cfg.response.status]); > + return -EINVAL; > + } > + > + return cfg.response.id; > +} > + > +static int > +dlb2_eventdev_dir_queue_setup(struct dlb2_eventdev *dlb2, > + struct dlb2_eventdev_queue *ev_queue, > + struct dlb2_eventdev_port *ev_port) > +{ > + int32_t qm_qid; > + > + qm_qid =3D dlb2_hw_create_dir_queue(dlb2, ev_queue, ev_port- > >qm_port.id); > + > + if (qm_qid < 0) { > + DLB2_LOG_ERR("Failed to create the DIR queue\n"); > + return qm_qid; > + } > + > + dlb2->qm_dir_to_ev_queue_id[qm_qid] =3D ev_queue->id; > + > + ev_queue->qm_queue.id =3D qm_qid; > + > + return 0; > +} > + > +static int > +dlb2_do_port_link(struct rte_eventdev *dev, > + struct dlb2_eventdev_queue *ev_queue, > + struct dlb2_eventdev_port *ev_port, > + uint8_t prio) > +{ > + struct dlb2_eventdev *dlb2 =3D dlb2_pmd_priv(dev); > + int err; > + > + /* Don't link until start time. */ > + if (dlb2->run_state =3D=3D DLB2_RUN_STATE_STOPPED) > + return 0; > + > + if (ev_queue->qm_queue.is_directed) > + err =3D dlb2_eventdev_dir_queue_setup(dlb2, ev_queue, > ev_port); > + else > + err =3D dlb2_event_queue_join_ldb(dlb2, ev_port, ev_queue, > prio); > + > + if (err) { > + DLB2_LOG_ERR("port link failure for %s ev_q %d, ev_port %d\n", > + ev_queue->qm_queue.is_directed ? "DIR" : "LDB", > + ev_queue->id, ev_port->id); > + > + rte_errno =3D err; > + return -1; > + } > + > + return 0; > +} > + > +static int > +dlb2_validate_port_link(struct dlb2_eventdev_port *ev_port, > + uint8_t queue_id, > + bool link_exists, > + int index) > +{ > + struct dlb2_eventdev *dlb2 =3D ev_port->dlb2; > + struct dlb2_eventdev_queue *ev_queue; > + bool port_is_dir, queue_is_dir; > + > + if (queue_id > dlb2->num_queues) { > + rte_errno =3D -EINVAL; > + return -1; > + } > + > + ev_queue =3D &dlb2->ev_queues[queue_id]; > + > + if (!ev_queue->setup_done && > + ev_queue->qm_queue.config_state !=3D DLB2_PREV_CONFIGURED) { > + rte_errno =3D -EINVAL; > + return -1; > + } > + > + port_is_dir =3D ev_port->qm_port.is_directed; > + queue_is_dir =3D ev_queue->qm_queue.is_directed; > + > + if (port_is_dir !=3D queue_is_dir) { > + DLB2_LOG_ERR("%s queue %u can't link to %s port %u\n", > + queue_is_dir ? "DIR" : "LDB", ev_queue->id, > + port_is_dir ? "DIR" : "LDB", ev_port->id); > + > + rte_errno =3D -EINVAL; > + return -1; > + } > + > + /* Check if there is space for the requested link */ > + if (!link_exists && index =3D=3D -1) { > + DLB2_LOG_ERR("no space for new link\n"); > + rte_errno =3D -ENOSPC; > + return -1; > + } > + > + /* Check if the directed port is already linked */ > + if (ev_port->qm_port.is_directed && ev_port->num_links > 0 && > + !link_exists) { > + DLB2_LOG_ERR("Can't link DIR port %d to >1 queues\n", > + ev_port->id); > + rte_errno =3D -EINVAL; > + return -1; > + } > + > + /* Check if the directed queue is already linked */ > + if (ev_queue->qm_queue.is_directed && ev_queue->num_links > 0 && > + !link_exists) { > + DLB2_LOG_ERR("Can't link DIR queue %d to >1 ports\n", > + ev_queue->id); > + rte_errno =3D -EINVAL; > + return -1; > + } > + > + return 0; > +} > + > +static int > +dlb2_eventdev_port_link(struct rte_eventdev *dev, void *event_port, > + const uint8_t queues[], const uint8_t priorities[], > + uint16_t nb_links) > + > +{ > + struct dlb2_eventdev_port *ev_port =3D event_port; > + struct dlb2_eventdev *dlb2; > + int i, j; > + > + RTE_SET_USED(dev); > + > + if (!ev_port) { > + DLB2_LOG_ERR("dlb2: evport not setup\n"); > + rte_errno =3D -EINVAL; > + return 0; > + } > + > + if (!ev_port->setup_done && > + ev_port->qm_port.config_state !=3D DLB2_PREV_CONFIGURED) { > + DLB2_LOG_ERR("dlb2: evport not setup\n"); > + rte_errno =3D -EINVAL; > + return 0; > + } > + > + /* Note: rte_event_port_link() ensures the PMD won't receive a NULL > + * queues pointer. > + */ > + if (nb_links =3D=3D 0) { > + DLB2_LOG_DBG("dlb2: nb_links is 0\n"); > + return 0; /* Ignore and return success */ > + } > + > + dlb2 =3D ev_port->dlb2; > + > + DLB2_LOG_DBG("Linking %u queues to %s port %d\n", > + nb_links, > + ev_port->qm_port.is_directed ? "DIR" : "LDB", > + ev_port->id); > + > + for (i =3D 0; i < nb_links; i++) { > + struct dlb2_eventdev_queue *ev_queue; > + uint8_t queue_id, prio; > + bool found =3D false; > + int index =3D -1; > + > + queue_id =3D queues[i]; > + prio =3D priorities[i]; > + > + /* Check if the link already exists. */ > + for (j =3D 0; j < DLB2_MAX_NUM_QIDS_PER_LDB_CQ; j++) > + if (ev_port->link[j].valid) { > + if (ev_port->link[j].queue_id =3D=3D queue_id) { > + found =3D true; > + index =3D j; > + break; > + } > + } else if (index =3D=3D -1) { > + index =3D j; > + } Nit: braces discouraged on a single-statement conditionals Thanks, Gage