svn commit: r343062 - in stable/12/sys/dev/cxgbe: . tom

John Baldwin jhb at FreeBSD.org
Tue Jan 15 21:33:28 UTC 2019


Author: jhb
Date: Tue Jan 15 21:33:26 2019
New Revision: 343062
URL: https://svnweb.freebsd.org/changeset/base/343062

Log:
  MFC 340466,340473: Move the TLS key map into the adapter softc.
  
  340466:
  Move the TLS key map into the adapter softc so non-TOE code can use it.
  
  340473:
  Restore the <sys/vmem.h> header to fix build of cxgbe(4) TOM.
  
  vmem's are not just used for TLS memory in TOM and the #include actually
  predates the TLS code so should not have been removed when the TLS vmem
  moved in r340466.

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/t4_main.c
  stable/12/sys/dev/cxgbe/tom/t4_tls.c
  stable/12/sys/dev/cxgbe/tom/t4_tom.c
  stable/12/sys/dev/cxgbe/tom/t4_tom.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/adapter.h
==============================================================================
--- stable/12/sys/dev/cxgbe/adapter.h	Tue Jan 15 21:07:40 2019	(r343061)
+++ stable/12/sys/dev/cxgbe/adapter.h	Tue Jan 15 21:33:26 2019	(r343062)
@@ -41,6 +41,7 @@
 #include <sys/malloc.h>
 #include <sys/rwlock.h>
 #include <sys/sx.h>
+#include <sys/vmem.h>
 #include <vm/uma.h>
 
 #include <dev/pci/pcivar.h>
@@ -823,6 +824,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: stable/12/sys/dev/cxgbe/t4_main.c
==============================================================================
--- stable/12/sys/dev/cxgbe/t4_main.c	Tue Jan 15 21:07:40 2019	(r343061)
+++ stable/12/sys/dev/cxgbe/t4_main.c	Tue Jan 15 21:33:26 2019	(r343062)
@@ -1151,6 +1151,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
@@ -1436,6 +1439,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: stable/12/sys/dev/cxgbe/tom/t4_tls.c
==============================================================================
--- stable/12/sys/dev/cxgbe/tom/t4_tls.c	Tue Jan 15 21:07:40 2019	(r343061)
+++ stable/12/sys/dev/cxgbe/tom/t4_tls.c	Tue Jan 15 21:33:26 2019	(r343062)
@@ -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: stable/12/sys/dev/cxgbe/tom/t4_tom.c
==============================================================================
--- stable/12/sys/dev/cxgbe/tom/t4_tom.c	Tue Jan 15 21:07:40 2019	(r343061)
+++ stable/12/sys/dev/cxgbe/tom/t4_tom.c	Tue Jan 15 21:33:26 2019	(r343062)
@@ -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: stable/12/sys/dev/cxgbe/tom/t4_tom.h
==============================================================================
--- stable/12/sys/dev/cxgbe/tom/t4_tom.h	Tue Jan 15 21:07:40 2019	(r343061)
+++ stable/12/sys/dev/cxgbe/tom/t4_tom.h	Tue Jan 15 21:33:26 2019	(r343062)
@@ -280,8 +280,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 +424,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 *);


More information about the svn-src-all mailing list