From owner-svn-src-all@freebsd.org Thu Nov 15 23:00:32 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0B556110CED6; Thu, 15 Nov 2018 23:00:32 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8ADFC83CA0; Thu, 15 Nov 2018 23:00:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 681AA14FAA; Thu, 15 Nov 2018 23:00:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wAFN0VDa055380; Thu, 15 Nov 2018 23:00:31 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wAFN0UK8055372; Thu, 15 Nov 2018 23:00:30 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201811152300.wAFN0UK8055372@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 15 Nov 2018 23:00:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r340466 - in head/sys/dev/cxgbe: . tom X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head/sys/dev/cxgbe: . tom X-SVN-Commit-Revision: 340466 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8ADFC83CA0 X-Spamd-Result: default: False [-106.88 / 40.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; ALLOW_DOMAIN_WHITELIST(-100.00)[FreeBSD.org]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; HAS_XAW(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; DMARC_NA(0.00)[FreeBSD.org]; RCVD_COUNT_THREE(0.00)[4]; MX_GOOD(-0.01)[cached: mx1.FreeBSD.org]; NEURAL_HAM_SHORT(-1.00)[-1.000,0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; IP_SCORE(-3.77)[ip: (-9.91), ipnet: 2610:1c1:1::/48(-4.93), asn: 11403(-3.91), country: US(-0.10)] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Nov 2018 23:00:32 -0000 Author: jhb Date: Thu Nov 15 23:00:30 2018 New Revision: 340466 URL: https://svnweb.freebsd.org/changeset/base/340466 Log: Move the TLS key map into the adapter softc so non-TOE code can use it. Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/adapter.h head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/tom/t4_tls.c head/sys/dev/cxgbe/tom/t4_tom.c head/sys/dev/cxgbe/tom/t4_tom.h Modified: head/sys/dev/cxgbe/adapter.h ============================================================================== --- head/sys/dev/cxgbe/adapter.h Thu Nov 15 22:47:47 2018 (r340465) +++ head/sys/dev/cxgbe/adapter.h Thu Nov 15 23:00:30 2018 (r340466) @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -826,6 +827,7 @@ struct adapter { struct l2t_data *l2t; /* L2 table */ struct smt_data *smt; /* Source MAC Table */ struct tid_info tids; + vmem_t *key_map; uint8_t doorbells; int offload_map; /* ports with IFCAP_TOE enabled */ Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Thu Nov 15 22:47:47 2018 (r340465) +++ head/sys/dev/cxgbe/t4_main.c Thu Nov 15 23:00:30 2018 (r340466) @@ -1153,6 +1153,9 @@ t4_attach(device_t dev) #ifdef RATELIMIT t4_init_etid_table(sc); #endif + if (sc->vres.key.size != 0) + sc->key_map = vmem_create("T4TLS key map", sc->vres.key.start, + sc->vres.key.size, 8, 0, M_FIRSTFIT | M_WAITOK); /* * Second pass over the ports. This time we know the number of rx and @@ -1438,6 +1441,8 @@ t4_detach_common(device_t dev) #ifdef RATELIMIT t4_free_etid_table(sc); #endif + if (sc->key_map) + vmem_destroy(sc->key_map); #if defined(TCP_OFFLOAD) || defined(RATELIMIT) free(sc->sge.ofld_txq, M_CXGBE); Modified: head/sys/dev/cxgbe/tom/t4_tls.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tls.c Thu Nov 15 22:47:47 2018 (r340465) +++ head/sys/dev/cxgbe/tom/t4_tls.c Thu Nov 15 23:00:30 2018 (r340466) @@ -429,32 +429,13 @@ prepare_txkey_wr(struct tls_keyctx *kwr, struct tls_ke } /* TLS Key memory management */ -int -tls_init_kmap(struct adapter *sc, struct tom_data *td) -{ - - td->key_map = vmem_create("T4TLS key map", sc->vres.key.start, - sc->vres.key.size, 8, 0, M_FIRSTFIT | M_NOWAIT); - if (td->key_map == NULL) - return (ENOMEM); - return (0); -} - -void -tls_free_kmap(struct tom_data *td) -{ - - if (td->key_map != NULL) - vmem_destroy(td->key_map); -} - static int get_new_keyid(struct toepcb *toep, struct tls_key_context *k_ctx) { - struct tom_data *td = toep->td; + struct adapter *sc = td_adapter(toep->td); vmem_addr_t addr; - if (vmem_alloc(td->key_map, TLS_KEY_CONTEXT_SZ, M_NOWAIT | M_FIRSTFIT, + if (vmem_alloc(sc->key_map, TLS_KEY_CONTEXT_SZ, M_NOWAIT | M_FIRSTFIT, &addr) != 0) return (-1); @@ -464,9 +445,9 @@ get_new_keyid(struct toepcb *toep, struct tls_key_cont static void free_keyid(struct toepcb *toep, int keyid) { - struct tom_data *td = toep->td; + struct adapter *sc = td_adapter(toep->td); - vmem_free(td->key_map, keyid, TLS_KEY_CONTEXT_SZ); + vmem_free(sc->key_map, keyid, TLS_KEY_CONTEXT_SZ); } static void Modified: head/sys/dev/cxgbe/tom/t4_tom.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tom.c Thu Nov 15 22:47:47 2018 (r340465) +++ head/sys/dev/cxgbe/tom/t4_tom.c Thu Nov 15 23:00:30 2018 (r340466) @@ -1093,7 +1093,6 @@ free_tom_data(struct adapter *sc, struct tom_data *td) KASSERT(td->lctx_count == 0, ("%s: lctx hash table is not empty.", __func__)); - tls_free_kmap(td); t4_free_ppod_region(&td->pr); destroy_clip_table(sc, td); @@ -1372,12 +1371,6 @@ t4_tom_activate(struct adapter *sc) /* CLIP table for IPv6 offload */ init_clip_table(sc, td); - - if (sc->vres.key.size != 0) { - rc = tls_init_kmap(sc, td); - if (rc != 0) - goto done; - } /* toedev ops */ tod = &td->tod; Modified: head/sys/dev/cxgbe/tom/t4_tom.h ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tom.h Thu Nov 15 22:47:47 2018 (r340465) +++ head/sys/dev/cxgbe/tom/t4_tom.h Thu Nov 15 23:00:30 2018 (r340466) @@ -32,7 +32,6 @@ #ifndef __T4_TOM_H__ #define __T4_TOM_H__ -#include #include "tom/t4_tls.h" #define LISTEN_HASH_SIZE 32 @@ -280,8 +279,6 @@ struct tom_data { struct ppod_region pr; - vmem_t *key_map; - struct mtx clip_table_lock; struct clip_head clip_table; int clip_gen; @@ -426,8 +423,6 @@ void t4_push_tls_records(struct adapter *, struct toep void t4_tls_mod_load(void); void t4_tls_mod_unload(void); void tls_establish(struct toepcb *); -void tls_free_kmap(struct tom_data *); -int tls_init_kmap(struct adapter *, struct tom_data *); void tls_init_toep(struct toepcb *); int tls_rx_key(struct toepcb *); void tls_stop_handshake_timer(struct toepcb *);