From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0045.outbound.protection.outlook.com [104.47.33.45]) by dpdk.org (Postfix) with ESMTP id A48A9590E for ; Fri, 28 Oct 2016 14:30:44 +0200 (CEST) Received: from CY1PR03CA0001.namprd03.prod.outlook.com (10.174.128.11) by SN2PR03MB2382.namprd03.prod.outlook.com (10.166.210.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Fri, 28 Oct 2016 12:30:43 +0000 Received: from BN1BFFO11FD028.protection.gbl (2a01:111:f400:7c10::1:111) by CY1PR03CA0001.outlook.office365.com (2603:10b6:600::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12 via Frontend Transport; Fri, 28 Oct 2016 12:30:43 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD028.mail.protection.outlook.com (10.58.144.91) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.679.5 via Frontend Transport; Fri, 28 Oct 2016 12:30:42 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u9SCPEMJ019399; Fri, 28 Oct 2016 05:30:39 -0700 From: Shreyansh Jain To: Date: Fri, 28 Oct 2016 17:56:24 +0530 Message-ID: <1477657598-826-8-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477657598-826-1-git-send-email-shreyansh.jain@nxp.com> References: <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> <1477657598-826-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131221314431798613; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(68736007)(33646002)(86362001)(77096005)(229853001)(2906002)(2351001)(92566002)(305945005)(97736004)(5890100001)(85426001)(47776003)(36756003)(11100500001)(6666003)(104016004)(5003940100001)(586003)(2950100002)(6916009)(19580405001)(19580395003)(110136003)(189998001)(5660300001)(50226002)(87936001)(105606002)(76176999)(50986999)(626004)(106466001)(8666005)(4326007)(7846002)(356003)(81166006)(50466002)(8936002)(81156014)(8676002)(48376002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2382; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD028; 1:Bz64BPNoZ356yH1EWtSjKehoo7BGQwYm81dsjkv1V9NZGXABj3Qh6ShjjxAk66MUCxz2Lz0s2Oeh0nltuKIOf+7mGZ6I05v7d6jqyVkVq4ERoL1UXaskLuK0lg7ltQGp28Yg5ImgtADvIUGoox2jLSI7fBqDl0u7Sb/5TQsPENVqd7L1ffexImidRdoGcSMyxzByO8CvccdTS4LDrD4L95L6ekLb4Ni91xnMz0/gQ1dXlyshDZD4JGnnBopx0Y+JRtNRmfIWlGhvx8OVxWUnPq/NJ3hr5Bm9i280BConE394ze3IsJG/Pd0IfFjX+89G/pzbapqYuDNP5Q7Zij00jVGeQPUAm6eTFdoY4CrfCbhN+TUG7pPRrDuiop0vIj9J68X5xq6doukEfqc+h9NXBgKCXGuAO8RXICvD1aKH2vwecyR++7Z7A0Oo6PDLhdqJdDW6VftV1P0MJudT6yv5cTqtMX/IVmIWC0QjUKWfBHcHQ/VTInj5D5rcrVRwDbxc7PwZum43DFYW9mJXB2T/4uK+719EA36UZqfG8UnCHelLXQRsmeqfv9rh05i0Gxe7upDuAu+dn1gcLMx9LwGElbTGrKRhKAG9tbVc3aYYxfHRxw40m9vgjnI/dXvkWlGbz/xQBJ/trQwkmsvxB7IiTBe/4gXErqHDGZz/eVjX3jV77lCA7K+N+xtcxnjBYM9WDGgwVJuks6usDRz648GcqxcZuBip7PLGtUd4b1a4H6g= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: b5ad4cc2-549e-492a-6bf5-08d3ff2e3c1f X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2382; 2:t/PBbSDS9CgbAzM7EqZ9op9fAXwzqOPhK1+3xp4ZDxp7QdhCUYNAC6C0W9YnmGgGmGB+bFhUavVvbpsfttDAx3VfpgAANIaR0BTWDC/KjsmBQJXLXqUrau5YbG22TCC5p57FiN8yfFijyawrb7hMKS40+cXQHaRscWRLchYnRPGwH6rDP4+ZBoSvBCWhJym3bdyP52JtXxIt82dzwbwSQQ==; 3:P67gW0dfaGvFnBRr2adSpzVNPfLTTcSBVZSlhrIUeW+f6RGMs7Qw0iZdMOp9cxVREZLEKjrQlqdZXTS8PwyNQbYAru/k48/eNmWIxmcY5l1oILZ2PkbFD18zwBDhEce95XAwrnd29Y8gQChmUfLOkIcp2F3Is8mcwJmZduICGWUswJkdZooO3XI8bfJRSTuoowLVa3LifcfALnXa85uV0K6u8VdU3Ul1f8RdmjsM8lDFpmqNQgUbfeF9lZ7ucLzQ X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR03MB2382; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2382; 25:0pEbDmeaN46BLNX07nz0Ts/na+Q3J/4jtC8xsu+KQeGt5YG/Xytts/ylUMzuzZ1Tqc3eOeChDhswEqQtes9p15bWr+l22bcygrXZLQSzgvIqSnmB6/GBrucOffmkUyztwlTuaPTnpHP4FH7RMfps6sDNPfkmDRsCjgBZGAHJ76Pw3/1bogQl/nC3KkdABeYARX+u5u4L2udFzGEeJy8mFSgEh6/XuFIeZE5it4ztfNolgYDx2oC29rUvBEXxXEVapXpOBqmRLK3qouvcUICuKxS9FPw7tfwV91aQWvuwWPHSZ7/UeBP/LcHyltTIOlAzzoLqRicNWu2iSympBvM3/aGKDMlnkXOfa/WoyFpDUegldDpKP42f+2lT4Ni2sOLPBqBsJy5Rv6J+JD7f+Iu18+y/Vk446ESk9Alc/hfxRXdN0rGPwOpjLp6VPEcMNvZor1/tnzQk9dkXDzohGdc/LdvmurlFnv/3lgr/Ka7qtrRHUeqcUTYSQU4pj8BbWWbO1nZHOgixSE2TyPAAq7AdWHx4pdqbqPFlhoh8d5xENLu0Q/HrVkj4Bo4SbLSJpvD1BsROWZ+kMTxt0hIXkoyxeXsLLZsHndVJHuJ53mr7LnKl2Zfpr1JyviesjAymE8hcjOFm8ywirLny6G/UXEKZ1fJlAtjwRbgf5RFH26G6LNx8FU6hkUsxeff7QQe4PZ85HvwtCYDq1Oy5M0FBpXNjsAWjAaWZFj85a2u6gJZqxtZFw2iv3jwdOHMzS1v38YKh+JaoXBeNRhe0JgqlHJRXvQKev/I5R00f61Qfb4x5FXohCVEdhJiOuItZWEM45AH5 X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2382; 31:HdxMQhaM6FqpyQxuDnPr4QhEz/nZLgMVYFWWqp9IKmniWjTZi4y88JW1Gv5M8FzXHP6F/ej10w3597LwIkwcJTEqeFO6/XJFsFV+DEtBEWudkfHrMYxBc7aPXaOFXOW1QQjJT9tKnknXgbN/jaCBICLBflRXv9rgU3RwtfmPZR0Sm9mtpb+Arvr0dm93oTmilysVxzXvozzuLTJUXw8p0F9p20zusR2B6zDdzkQG/Gxpb9wNhNKSHatP+YNJw/UIZ4bDGTDd2XbOrFSdLk9svtDt2CIVH+MHepHcrbFUHNY=; 4:uciZNDGCP6vQkU6xaJ5wrlkqw8jlM+6Q3C4iR6D19/9O0UfSZHHWIKz6zrDNe+d/S4O9YD9UYA5pP0C62yKyb/Dnz9VGhINJADtynPZggyjLRuu7LYM5pD0EnnfchgwLSzwNSM9+WPK6Z/T347a3s2qtKn/HQZ2wxnIGD/QvOGI0qNpXFy7jeUP40bZFBzN1jacPj9fscA+Gs50Zf+5D1hwuf+++GLfvIYj3sNKERXexho7MS3iVTlbbYS8xLzjxGHwJdFYmgby8SEEo++/jYRVqKjYeFRLRzrPvjnxJwNbyPPr1lfdvdGjztbfoM3kzmx4w1q6pKWgYwV7f2Z8AkoIkpN1YWRtgxNU84W+qd/kGACHn8bnIskeGDlVPoHLlKIxFDG0xSeixvJ2YAwYsehIRs8ylGJQhPABS8rkQPKl3NEZ5QgNeML0yS2dxy3ZodIuAK60fqChfU9+xkhnGyGV5wezYnq3+NDVHzURMFoy4TyRNKt+0PKLpLUy3N6HZT1rJPOUFdrhER+hLO9idJIElG70xEmEKnOrg75l6TG012HAsqPnHIAYvcEx8s8Sl X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13017025)(13015025)(13018025)(13024025)(5005006)(8121501046)(13023025)(3002001)(10201501046)(6055026); SRVR:SN2PR03MB2382; BCL:0; PCL:0; RULEID:(400006); SRVR:SN2PR03MB2382; X-Forefront-PRVS: 0109D382B0 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR03MB2382; 23:1SO4E7Twza1UoHIXnprx9grqZsreJzsUfF3tQNKsW?= =?us-ascii?Q?yyKnJh9t9XXZ7wJVL0KerAfyfu0XuL/9Qv7Vl4GLPKVOJMX5WPDLC79Wcx8T?= =?us-ascii?Q?a9fJpeNand6lo1i3eSmcurBm8/RDsiSjKnIsj5LJFW/P9psBTL44pJ/7KlDi?= =?us-ascii?Q?8Sf5OxER8QPK+kS2xHzgZoT0E6Wb8fpX+l97WW22oi9dkSDGPI/mhhhoP7cH?= =?us-ascii?Q?Z2uowBAqpdBv8eg0LSfoFIeeya2LjY+Pwiw699KRdk/qw+Xnck72dCrZon33?= =?us-ascii?Q?204zawAOMywIp76ieWPldVxtuobf0XG/u5egjdehY+KeBT+Bs83Uj8p6Civl?= =?us-ascii?Q?7QKyPIYW9zs0uuq3btbPCAGORPyv6dTNqXzd4tT1DROWLuyda0yQjUQqqDXo?= =?us-ascii?Q?YnAqRLdGru3n9rOUj0uhT+xvqelF3S+C1W/uWF3B2UpzOnpLPqswF3i7uBcY?= =?us-ascii?Q?SLeAz13848biaXUnnBGp3r0WzalpWQsRXRtFqMhmOHcK7+RHaf90JEQK47Ib?= =?us-ascii?Q?xSXKravt7xHHTIAjs0oihN1EUV2dJ280afC1b6fZZO7imCBt7as0yBbIPu2N?= =?us-ascii?Q?Kc4zfUKpNpKzuT9+ykrl/wxSPYWcLS+fLptIbiTEfH+7AC9btEeOuwzE3ROv?= =?us-ascii?Q?98yjgRGETTjGoxt5Az0UE5gbVBgyKTCu+5rXwXD+q1uvbfM16oIb3m9SBy6K?= =?us-ascii?Q?GLibtH+lNU7Jb/8Wpih4ihcVDFZUweHviJvQbEhOj+35x85pODRYvWwL7CcI?= =?us-ascii?Q?APTwki6IC//rWxT3VmRxciFo94OLJn/fkRFk/tV0WhDslwpk2Qj26MaRrsd0?= =?us-ascii?Q?Z+zNx6gw5BWGeLPnZEHLYIm3+j83hV8TY1o5KUnLAEsvUmbv9zX0ez9M25nk?= =?us-ascii?Q?vzZPX6k5mrzKlJ+1nKlRarFq5plsl1vtkbHetdmZi07GfuYf00zz3IZxR4yx?= =?us-ascii?Q?row8MkvIzkiNoQ9KV/odGt3s55+eGE+reEwTm61Rmwq8V1QNIcEVf3qc5qcD?= =?us-ascii?Q?ZAqw9jCFDj+rNbU41udcB9ADQjEbSPwbp3AmRv5IiaCuG6JT1J6UIcJ7ju0/?= =?us-ascii?Q?L37vHw0zUWu3mIDEcFPFEJUHFNrBq5nKF5u5EzGnpc70Gk7VzbPlR8URh0qp?= =?us-ascii?Q?vgtuetmrDLCyz9XE0nvAbkJvj8bXECR3IcyfETRb6KTo2MsIX/t/cmwKeEg8?= =?us-ascii?Q?oeE2tK0KxKxFGdffTOINS0TSESgeMi2Q49F2ipwlpKd2XdD/TBf4bYQHo5Ow?= =?us-ascii?Q?6qZR6a8cnGEgg4VB4s=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2382; 6:wME3mtsLTb5pi7SJKP6VkkWcxuV65F0xNmdOJm+Rt/QSnYiIuVLUk1eC8IcD7m1vVhP8vG8uBY5G77PSY6nrwwG4h5MF45Gx7GneCxd0vlbbBYCSFYGVWq/LQLr1TWhwbeT9vrtLX+POK4eoIzuGfVpBT7hQqxxD6yh6J6CM1t+lhy9LZ5x+C9Aatw7s62cePzopGkjfLtWPxKNnzwfToMzfodNbmBeawaWabg68un9kI3D2Nf52pcH4/9mPKploM7OGU7Rtsge+E/ZkxZyTAKgNcQ8emTd7p2bk7TYYL36pCdoG9rxZooCWtawtQf+U; 5:y8ei9A/rJMYnDyolcuMJrufvG1wo7RAbXt6neAxuoilDRPW+zwTLQZuRwHbfHn7zyiRBiMTz8160ldqbjcAFi83542G100IznLkFWNgfThg1ckKkH6zozMnWZjTgaQb3A9cjpJuc2uWUmUMi6n+etRUWhANwDlveXHLChprafGRQ+VPqk2MBveN4lHkLYCeQ; 24:6QHm36km+Kf16/oo6C1AUo+Nu6P4cC82MzK0g6VrK1z8++44zpONvKyOSbkcmbhFjEWtKAgnDeO5ZFQqu7loBSbsuW0L7n9fToE5zFMoAhw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2382; 7:CoQkk4Wixq/0jPv3OxVk5AXzjt3+QLCqrSlHSnZpKawber4DOnlxaI8CcphbwrCk6Hg+GwDKMOwkSSI81MUaY8x6AEkOzPmiIuLgYT3vlCf4+QrsL/yvngAjO34oFUYj5RYIhmHnPChk/rcf1B4iId++nl8YPKPFoxd4ysVWDcJsflkV9a/iW6dG+bo7T+RiEU5k12Vh38jXizJu8RZqZjMd3dNpEbJVyxfVh866iYl+5obxvnJeeaP+howS43/3AjldZbfrETB3TbV2n+crdL9WLglAnOF2K1DDuym7PFABjcFZSzKnSkDSvEVFypz8kHdu5iFZvC1gtfeJsyJYAJ1V7Bc8fJU83xt2bhgr4HU= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2016 12:30:42.7586 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2382 Cc: Shreyansh Jain , thomas.monjalon@6wind.com, viktorin@rehivetech.com Subject: [dpdk-dev] [PATCH v7 07/21] eal/soc: add SoC PMD register/unregister logic X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2016 12:30:45 -0000 From: Jan Viktorin Registeration of a SoC driver through a helper RTE_PMD_REGISTER_SOC (on the lines of RTE_PMD_REGISTER_PCI). soc_driver_list stores all the registered drivers. Test case has been introduced to verify the registration and deregistration. Signed-off-by: Jan Viktorin [Shreyansh: update PMD registration method] Signed-off-by: Shreyansh Jain Signed-off-by: Hemant Agrawal --- app/test/test_soc.c | 111 ++++++++++++++++++++++++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 3 + lib/librte_eal/common/eal_common_soc.c | 56 ++++++++++++ lib/librte_eal/common/include/rte_soc.h | 26 ++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 3 + 6 files changed, 200 insertions(+) create mode 100644 lib/librte_eal/common/eal_common_soc.c diff --git a/app/test/test_soc.c b/app/test/test_soc.c index 916a863..ac03e64 100644 --- a/app/test/test_soc.c +++ b/app/test/test_soc.c @@ -75,6 +75,108 @@ static int test_compare_addr(void) free(a2.name); free(a1.name); free(a0.name); + + return 0; +} + +/** + * Empty PMD driver based on the SoC infra. + * + * The rte_soc_device is usually wrapped in some higher-level struct + * (eth_driver). We simulate such a wrapper with an anonymous struct here. + */ +struct test_wrapper { + struct rte_soc_driver soc_drv; +}; + +struct test_wrapper empty_pmd0 = { + .soc_drv = { + .driver = { + .name = "empty_pmd0" + }, + }, +}; + +struct test_wrapper empty_pmd1 = { + .soc_drv = { + .driver = { + .name = "empty_pmd1" + }, + }, +}; + +static int +count_registered_socdrvs(void) +{ + int i; + struct rte_soc_driver *drv; + + i = 0; + TAILQ_FOREACH(drv, &soc_driver_list, next) + i += 1; + + return i; +} + +static int +test_register_unregister(void) +{ + struct rte_soc_driver *drv; + int count; + + rte_eal_soc_register(&empty_pmd0.soc_drv); + + TEST_ASSERT(!TAILQ_EMPTY(&soc_driver_list), + "No PMD is present but the empty_pmd0 should be there"); + drv = TAILQ_FIRST(&soc_driver_list); + TEST_ASSERT(!strcmp(drv->driver.name, "empty_pmd0"), + "The registered PMD is not empty_pmd0 but '%s'", + drv->driver.name); + + rte_eal_soc_register(&empty_pmd1.soc_drv); + + count = count_registered_socdrvs(); + TEST_ASSERT_EQUAL(count, 2, "Expected 2 PMDs but detected %d", count); + + rte_eal_soc_unregister(&empty_pmd0.soc_drv); + count = count_registered_socdrvs(); + TEST_ASSERT_EQUAL(count, 1, "Expected 1 PMDs but detected %d", count); + + rte_eal_soc_unregister(&empty_pmd1.soc_drv); + + printf("%s has been successful\n", __func__); + return 0; +} + +/* save real devices and drivers until the tests finishes */ +struct soc_driver_list real_soc_driver_list = + TAILQ_HEAD_INITIALIZER(real_soc_driver_list); + +static int test_soc_setup(void) +{ + struct rte_soc_driver *drv; + + /* no real drivers for the test */ + while (!TAILQ_EMPTY(&soc_driver_list)) { + drv = TAILQ_FIRST(&soc_driver_list); + rte_eal_soc_unregister(drv); + TAILQ_INSERT_TAIL(&real_soc_driver_list, drv, next); + } + + return 0; +} + +static int test_soc_cleanup(void) +{ + struct rte_soc_driver *drv; + + /* bring back real drivers after the test */ + while (!TAILQ_EMPTY(&real_soc_driver_list)) { + drv = TAILQ_FIRST(&real_soc_driver_list); + TAILQ_REMOVE(&real_soc_driver_list, drv, next); + rte_eal_soc_register(drv); + } + return 0; } @@ -84,6 +186,15 @@ test_soc(void) if (test_compare_addr()) return -1; + if (test_soc_setup()) + return -1; + + if (test_register_unregister()) + return -1; + + if (test_soc_cleanup()) + return -1; + return 0; } diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 11d9f59..cf6fb8e 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -171,8 +171,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_register; + rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; } DPDK_16.07; diff --git a/lib/librte_eal/common/eal_common_soc.c b/lib/librte_eal/common/eal_common_soc.c new file mode 100644 index 0000000..56135ed --- /dev/null +++ b/lib/librte_eal/common/eal_common_soc.c @@ -0,0 +1,56 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 RehiveTech. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of RehiveTech nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include + +#include "eal_private.h" + +/* Global SoC driver list */ +struct soc_driver_list soc_driver_list = + TAILQ_HEAD_INITIALIZER(soc_driver_list); + +/* register a driver */ +void +rte_eal_soc_register(struct rte_soc_driver *driver) +{ + TAILQ_INSERT_TAIL(&soc_driver_list, driver, next); +} + +/* unregister a driver */ +void +rte_eal_soc_unregister(struct rte_soc_driver *driver) +{ + TAILQ_REMOVE(&soc_driver_list, driver, next); +} diff --git a/lib/librte_eal/common/include/rte_soc.h b/lib/librte_eal/common/include/rte_soc.h index 5c32737..23b06a9 100644 --- a/lib/librte_eal/common/include/rte_soc.h +++ b/lib/librte_eal/common/include/rte_soc.h @@ -51,8 +51,14 @@ extern "C" { #include #include +#include #include +extern struct soc_driver_list soc_driver_list; +/**< Global list of SoC Drivers */ + +TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked Q. */ + struct rte_soc_id { const char *compatible; /**< OF compatible specification */ uint64_t priv_data; /**< SoC Driver specific data */ @@ -135,4 +141,24 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, return strcmp(a0->name, a1->name); } +/** + * Register a SoC driver. + */ +void rte_eal_soc_register(struct rte_soc_driver *driver); + +/** Helper for SoC device registeration from PMD Drivers */ +#define RTE_PMD_REGISTER_SOC(nm, soc_drv) \ +RTE_INIT(socinitfn_ ##name); \ +static void socinitfn_ ##name(void) \ +{\ + (soc_drv).driver.name = RTE_STR(nm);\ + rte_eal_soc_register(&soc_drv); \ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +/** + * Unregister a SoC driver. + */ +void rte_eal_soc_unregister(struct rte_soc_driver *driver); + #endif diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index 4e206f0..a520477 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -77,6 +77,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_soc.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 22b5b59..ab6b985 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -175,8 +175,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_register; + rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; } DPDK_16.07; -- 2.7.4