Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758489AbcLUJED (ORCPT ); Wed, 21 Dec 2016 04:04:03 -0500 Received: from mail-bn3nam01on0065.outbound.protection.outlook.com ([104.47.33.65]:21110 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756166AbcLUJDd (ORCPT ); Wed, 21 Dec 2016 04:03:33 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Satha.Rao@cavium.com; From: Satha Koteswara Rao To: CC: , , , , , , , , , Subject: [RFC PATCH 6/7] HW Filter Table access API's Date: Wed, 21 Dec 2016 14:16:50 +0530 Message-ID: <1482310011-1862-7-git-send-email-satha.rao@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1482310011-1862-1-git-send-email-satha.rao@caviumnetworks.com> References: <1482310011-1862-1-git-send-email-satha.rao@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MAXPR01CA0030.INDPRD01.PROD.OUTLOOK.COM (10.164.147.37) To CY4PR07MB2838.namprd07.prod.outlook.com (10.169.252.16) X-MS-Office365-Filtering-Correlation-Id: 09d733c3-e2ca-4445-6218-08d4297e2704 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY4PR07MB2838; X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB2838;3:l59IFwDPlN11Ve18npSDAogml0of2elaG4EMqypLBIVJba4xUJMP3u3oo4llqUc0seVgW0TLq52EUkTDtLEv4QSYkr9ZMmow55i6eWIE8Na0pZneROF8icuU07bX/wUEq3TTnjc2lvAkxu4BSZH0luL9T65OV4m/1aDyK/CCSJWtJYI711zCzuZI2Z4uxD6vEZAwo5lCTgMWxG90XVyzIwod/DXG+eQ6hHs0hBPptPB1gvZQBQmFSuu53kAgOC/fz9oOtRZ76oe/4T2xwDrHig==;25:UA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FnmOM2nlEKRzLxaF8FO/KUKPRfwbeMqHLkB4XP1KdYRiV2nUiaiAbWEt26UpyVY60w43ucDI9GXSReXBcAH5Lg9pdwl8rfcvcLyvFE+rMHtiJsufZR5LKYWQRe/ETC34MJubdIevS6tUovmd/hf01QgM76HAhbUHSxXLjaEN84vmxSrVV/T1YnRmpAt4iJaVt2t8ytFjPaoXYfp1s2BFbJftmgrHtkUPiEjNHe1TP9rkpwecccCUloPv65f88vRSBtcW8JDdMVl2nQeInYZS8Xk8v/B5sLwYy78hgUlAlqbsWN/G5rbflg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(6072148);SRVR:CY4PR07MB2838;BCL:0;PCL:0;RULEID:;SRVR:CY4PR07MB2838; X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB2838;4:fvZjc+wda/ma3TrDYLp11nBQjc+irVgCNNdO8u+Ifd8i3g5uvPrlpkyOI5SyIGtyKoPDbElHh81CTRr52jgzstLyV3S51/pymkOL4+QIwhYcj/hG84OZkw+ki2fgVX6yxpc/TigZPVNk7W+OazKth3EocgmjmjhdKMqUbfa/CXobwrRAqNdS5VEUjn9ZpGJgaTAW6ZK/uDafjk2cOY1ZTaVC7mdo51fyPmWrt1tUJB1Zwws80nCmxAzEH09KAxu2tAW7BotnplWEu/iQQ6UOnLbhMwV5nm+0JrHnDU43BFfsa/E/m4aCEPsuMZpwXiR2idcVfwtaul4w3ZtOJ8ki4ghIyE/2MYAHjJs0QWD8cx6IIf9jMLxlbIFMdsMPrc74cCyK6BD4C2jywM16GY2Vgpf+o1QsWuWA+cVJ7AkTVOIDuy/Sof7TJ3kfsaDPkazZ6sFco1ZyJVySamGdiIEH7FIZM0z+G5iExWv1q1Ex2Usr9ieoniojXwreGdWpFLU/pYDNQ5RcHnhCIp/kGTxCqyE8B+YLnmnJ+1R0lIzQLWclOTYO+jeHM9pCCwFSeDQq X-Forefront-PRVS: 01630974C0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(39450400003)(189002)(199003)(2906002)(4326007)(101416001)(33646002)(5009440100003)(106356001)(2351001)(68736007)(105586002)(8676002)(50986999)(5003940100001)(53416004)(76506005)(76176999)(48376002)(81156014)(81166006)(42186005)(66066001)(5660300001)(92566002)(50466002)(6506006)(575784001)(110136003)(7736002)(6916009)(47776003)(189998001)(36756003)(6116002)(6666003)(50226002)(3846002)(97736004)(42882006)(25786008)(2950100002)(305945005)(6512006)(69596002)(38730400001)(6486002)(4720700003)(7099028)(2004002)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR07MB2838;H:localhost.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR07MB2838;23:9xWhdmgY6/JCsvB0GoylHuFpMaFQCKLjJKtLuPo6w?= =?us-ascii?Q?q2S4zxLnKYYKuii6iePi7MJkiTFBbiwQdc1Xbns/EiyRu9umiFw5MOL3BGkF?= =?us-ascii?Q?+v4G0BlhutUJPJSJrvzkiEeOcINzh0tbe+TC60K5XkzHFKLgb7psGC7XH3Qe?= =?us-ascii?Q?3FHVoacN6cAnwah0U6qExusiVj/16K7h5i073sB1qXqMOiBwCOfqDyOs/pTG?= =?us-ascii?Q?hMQThkmsP5KOyy+9UMZSliHBRCo5C9tzPau8ENC3xwkEFyoSvlTmNZmopO+0?= =?us-ascii?Q?c8ZCzXyaUq+ZcIvdVsqODFXjnqJauYkW9jx6MxysUHimi9KYwiKHPkMcL5+r?= =?us-ascii?Q?Q9ymgdm8It4TfHix7l+9XslIWGSaq83dVf7eq3D3YtnPJ5uUMr428a6+kwG+?= =?us-ascii?Q?raO8ELPbPP6M223bxwCofv+k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zb?= =?us-ascii?Q?9DM0pP8AZSOFVkfOoMjUOI=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB2838;6:S1/tTWADVKDLi9DUZO/6gxbgNVXSx46SPVa2hBWry7sUFr9kDtrFN2yU/Ab2o6+dB2XYlWSJy3tOUAw9OaB6qzCXYeuXcMfs0p0lJ3dUFBDYIKCL75TwhKO5V1G7bCZbzTEGLHKbkD9GHhxaMMuR2njX4WC7m9qKc0deAXB1j2L7SUmQA/+KLu0VX0l6lsbHdx9LVN7X3g4EMHv30Fe1E1BZkQ5ecCW0vJ22qRpfsRLu/xnOo02KRyFATCxxMohi4xTFRPDzk2yayfkHEfB08Cyc3sWcsZwgAd+gyDpQdqdZcGNaPo9Ho8iDZTUVhYdxqUctKv6JzGa9nyNRQDChROYRK5M/U/9ziC3wQviDCHZVGSRi5pJ72H3zjrPUsdll846uKz8iuNDt134w+21t4OGYuHg+YmC7sRhP09wxYmc=;5:hcYrW8FTkZgNALtABzmtSom7w1K9EJ5tQrp7ga8XlKLYkEky2AO3XxHomyDNyqcmKqAeMBF5oEMIvMreEjG4dJ+3pICWF8Hpia1aUyGM1TLpP+0b7RCyV3gt0maI+VunXwVsVr/73jEXZ79KofxixA==;24:QauVyEvuVAvx8fYWaZv95KV97oz1Xl/bX80XgC+q1WYXbifKu7ZOW++5lfK5jo4ZUjHsjbdhNS9chUupSQe4J5O9x4RmEWp1IhOU4K3oGRQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB2838;7:OgbJ5YrcedDOOaGTcTCakACRf2POYmbOlObuYT1LAenDSloFYCLdmOtvFjG296A14mryHzwynfVdSKmMWb99rWWj48WB3gssTm0a/vcz34Xqn8xeBIwV5IYARYMOD1FwA5JvrLSlZrPPMWQnXWPxL1sDR3YCgG20U+zfXnpqqGWOsocDJbohXFnJbUp6T9BOjXjNloevvu75/8Q49edEvbYwXSdiNK4zwB/A5tsmYdkqAOpP9EZ7ILpmxeQsRYBGlrVY5mFKOFb2XSL9hVMAMT3lz9ekNmKz/Jy/ZDDH75pK+LGLBdxFtmqI9P+omiExBKM6ys21pV5ffsujkrm5axgKeMVUczpW4/ITRYeEpMJKkVgHLhdd3toLvXknT+qhlv5d7YEDJ7uep706381CoGRl+nEKkZk+CZ0Hob6zNijlJvZ0aTeL+flj4Ia+SrC67ap5Sg0TqGlUSrtcvBKPHw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2016 08:48:33.1793 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB2838 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9236 Lines: 344 --- drivers/net/ethernet/cavium/thunder/tbl_access.c | 262 +++++++++++++++++++++++ drivers/net/ethernet/cavium/thunder/tbl_access.h | 61 ++++++ 2 files changed, 323 insertions(+) create mode 100644 drivers/net/ethernet/cavium/thunder/tbl_access.c create mode 100644 drivers/net/ethernet/cavium/thunder/tbl_access.h diff --git a/drivers/net/ethernet/cavium/thunder/tbl_access.c b/drivers/net/ethernet/cavium/thunder/tbl_access.c new file mode 100644 index 0000000..6be31eb --- /dev/null +++ b/drivers/net/ethernet/cavium/thunder/tbl_access.c @@ -0,0 +1,262 @@ +/* + * Copyright (C) 2015 Cavium, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + */ + +#include +#include "pf_globals.h" +#include "pf_locals.h" +#include "tbl_access.h" + +struct tns_table_s *get_table_information(int table_id) +{ + int i; + + for (i = 0; i < TNS_MAX_TABLE; i++) { + if (!tbl_info[i].sdata.valid) + continue; + + if (tbl_info[i].sdata.tbl_id == table_id) + return &tbl_info[i]; + } + + return NULL; +} + +int tbl_write(int node, int table_id, int tbl_index, void *key, void *mask, + void *data) +{ + int i; + struct tns_table_s *tbl = get_table_information(table_id); + int bck_cnt, data_index, data_offset; + u64 data_entry[4]; + + if (!tbl) { + filter_dbg(FERR, "Invalid Table ID: %d\n", table_id); + return TNS_ERR_INVALID_TBL_ID; + } + + bck_cnt = tbl->sdata.data_width / tbl->sdata.data_size; + data_index = (tbl_index / bck_cnt); + data_offset = (tbl_index % bck_cnt); + //TCAM Table, we need to parse key & mask into single array + if (tbl->sdata.tbl_type == TNS_TBL_TYPE_TT) { + struct filter_keymask_s *tk = (struct filter_keymask_s *)key; + struct filter_keymask_s *tm = (struct filter_keymask_s *)mask; + u8 km[32]; + u64 mod_key, mod_mask, temp_mask; + int index = 0, offset = 0; + + memset(km, 0x0, 32); + +/* TCAM truth table data creation. Translation from data/mask to following + * truth table: + * + * Mask Data Content + * 0 0 X + * 0 1 1 + * 1 0 0 + * 1 1 Always Mismatch + * + */ + mod_mask = ~tk->key_value; + temp_mask = tm->key_value; + mod_key = tk->key_value; + mod_key = mod_key & (~temp_mask); + mod_mask = mod_mask & (~temp_mask); + + for (i = 0; i < 64; i++) { + km[index] = km[index] | (((mod_mask >> i) & 0x1) << + offset); + km[index] = km[index] | (((mod_key >> i) & 0x1) << + (offset + 1)); + offset += 2; + if (offset == 8) { + offset = 0; + index += 1; + } + } + km[index] = 0x2; + if (tns_write_register_indirect(node, + (tbl->sdata.key_base_addr + + (tbl_index * 32)), 32, + (void *)&km[0])) { + filter_dbg(FERR, "key write failed node %d tbl ID %d", + node, table_id); + filter_dbg(FERR, " index %d\n", tbl_index); + return TNS_ERR_DRIVER_WRITE; + } + } + + /* Data Writes are ReadModifyWrite */ + if (tns_read_register_indirect(node, (tbl->sdata.data_base_addr + + (data_index * 32)), 32, + (void *)&data_entry[0])) { + filter_dbg(FERR, "data read failed node %d tbl ID %d idx %d\n", + node, table_id, tbl_index); + return TNS_ERR_DRIVER_READ; + } + memcpy(&data_entry[data_offset], data, tbl->sdata.data_size / 8); + if (tns_write_register_indirect(node, (tbl->sdata.data_base_addr + + (data_index * 32)), 32, + (void *)&data_entry[0])) { + filter_dbg(FERR, "data write failed node %d tbl ID %d idx %d\n", + node, table_id, tbl_index); + return TNS_ERR_DRIVER_WRITE; + } + + return TNS_NO_ERR; +} + +int tbl_read(int node, int table_id, int tbl_index, void *key, void *mask, + void *data) +{ + struct tns_table_s *tbl = get_table_information(table_id); + int i, bck_cnt, data_index, data_offset; + u64 data_entry[4]; + u8 km[32]; + + if (!tbl) { + filter_dbg(FERR, "Invalid Table ID: %d\n", table_id); + return TNS_ERR_INVALID_TBL_ID; + } + + bck_cnt = tbl->sdata.data_width / tbl->sdata.data_size; + data_index = (tbl_index / bck_cnt); + data_offset = (tbl_index % bck_cnt); + + //TCAM Table, we need to parse key & mask into single array + if (tbl->sdata.tbl_type == TNS_TBL_TYPE_TT) { + memset(km, 0x0, 32); + + if (tns_read_register_indirect(node, (tbl->sdata.key_base_addr + + (tbl_index * 32)), 32, + (void *)&km[0])) { + filter_dbg(FERR, "key read failed node %d tbl ID %d", + node, table_id); + filter_dbg(FERR, " idx %d\n", tbl_index); + return TNS_ERR_DRIVER_READ; + } + if (!(km[((tbl->sdata.key_size * 2) / 8)] == 0x2)) + return TNS_ERR_MAC_FILTER_INVALID_ENTRY; + } + + if (tns_read_register_indirect(node, (tbl->sdata.data_base_addr + + (data_index * 32)), 32, + (void *)&data_entry[0])) { + filter_dbg(FERR, "data read failed node %d tbl ID %d idx %d\n", + node, table_id, tbl_index); + return TNS_ERR_DRIVER_READ; + } + memcpy(data, (void *)(&data_entry[data_offset]), + (tbl->sdata.data_size / 8)); + + if (tbl->sdata.tbl_type == TNS_TBL_TYPE_TT) { + struct filter_keymask_s *tk = (struct filter_keymask_s *)key; + struct filter_keymask_s *tm = (struct filter_keymask_s *)mask; + u8 temp_km; + int index = 0, offset = 0; + + tk->key_value = 0x0ull; + tm->key_value = 0x0ull; + temp_km = km[0]; + for (i = 0; i < 64; i++) { + tm->key_value = tm->key_value | + ((temp_km & 0x1ull) << i); + temp_km >>= 1; + tk->key_value = tk->key_value | + ((temp_km & 0x1ull) << i); + temp_km >>= 1; + offset += 2; + if (offset == 8) { + offset = 0; + index += 1; + temp_km = km[index]; + } + } + tm->key_value = ~tm->key_value & ~tk->key_value; + tk->is_valid = 1; + tm->is_valid = 0; + } + + return TNS_NO_ERR; +} + +int invalidate_table_entry(int node, int table_id, int tbl_idx) +{ + struct tns_table_s *tbl = get_table_information(table_id); + + if (!tbl) { + filter_dbg(FERR, "Invalid Table ID: %d\n", table_id); + return TNS_ERR_INVALID_TBL_ID; + } + + if (tbl->sdata.tbl_type == TNS_TBL_TYPE_TT) { + u8 km[32]; + + memset(km, 0x0, 32); + km[((tbl->sdata.key_size * 2) / 8)] = 0x1; + + if (tns_write_register_indirect(node, + (tbl->sdata.key_base_addr + + (tbl_idx * 32)), 32, + (void *)&km[0])) { + filter_dbg(FERR, "%s failed node %d tbl ID %d idx %d\n", + __func__, node, table_id, tbl_idx); + return TNS_ERR_DRIVER_WRITE; + } + } + + return TNS_NO_ERR; +} + +int alloc_table_index(int node, int table_id, int *index) +{ + int err = 0; + struct tns_table_s *tbl = get_table_information(table_id); + + if (!tbl) { + filter_dbg(FERR, "%s Invalid TableID %d\n", __func__, table_id); + return TNS_ERR_INVALID_TBL_ID; + } + + if (*index == -1) { + *index = find_first_zero_bit(tbl->ddata[node].bitmap, + tbl->sdata.depth); + + if (*index < 0 || *index >= tbl->sdata.depth) + err = -ENOSPC; + else + __set_bit(*index, tbl->ddata[node].bitmap); + + return err; + } else if (*index < 0 || *index >= tbl->sdata.depth) { + filter_dbg(FERR, "%s Out of bound index %d requested[0...%d]\n", + __func__, *index, tbl->sdata.depth); + return TNS_ERR_MAC_FILTER_INVALID_ENTRY; + } + if (test_and_set_bit(*index, tbl->ddata[node].bitmap)) + filter_dbg(FDEBUG, "%s Entry Already exists\n", __func__); + + return err; +} + +void free_table_index(int node, int table_id, int index) +{ + struct tns_table_s *tbl = get_table_information(table_id); + + if (!tbl) { + filter_dbg(FERR, "%s Invalid TableID %d\n", __func__, table_id); + return; + } + if (index < 0 || index >= tbl->sdata.depth) { + filter_dbg(FERR, "%s Invalid Index %d Max Limit %d\n", + __func__, index, tbl->sdata.depth); + return; + } + + __clear_bit(index, tbl->ddata[node].bitmap); +} diff --git a/drivers/net/ethernet/cavium/thunder/tbl_access.h b/drivers/net/ethernet/cavium/thunder/tbl_access.h new file mode 100644 index 0000000..c098410 --- /dev/null +++ b/drivers/net/ethernet/cavium/thunder/tbl_access.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2015 Cavium, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + */ + +#ifndef __TBL_ACCESS_H__ +#define __TBL_ACCESS_H__ + +#define TNS_MAX_TABLE 8 + +enum { + TNS_TBL_TYPE_DT, + TNS_TBL_TYPE_HT, + TNS_TBL_TYPE_TT, + TNS_TBL_TYPE_MAX +}; + +struct table_static_s { + u8 tbl_type; + u8 tbl_id; + u8 valid; + u8 rsvd; + u16 key_size; + u16 data_size; + u16 data_width; + u16 key_width; + u32 depth; + u64 key_base_addr; + u64 data_base_addr; + u8 tbl_name[32]; +}; + +struct table_dynamic_s { + unsigned long *bitmap; +}; + +struct tns_table_s { + struct table_static_s sdata; + struct table_dynamic_s ddata[MAX_NUMNODES]; +}; + +enum { + MAC_FILTER_TABLE = 102, + VLAN_FILTER_TABLE = 103, + MAC_EVIF_TABLE = 140, + VLAN_EVIF_TABLE = 201, + PORT_CONFIG_TABLE = 202, + TABLE_ID_END +}; + +extern struct tns_table_s tbl_info[TNS_MAX_TABLE]; + +struct filter_keymask_s { + u8 is_valid; + u64 key_value; +}; + +#endif /* __TBL_ACCESS_H__ */ -- 1.8.3.1