Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Nov 2018 23:00:30 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
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
Message-ID:  <201811152300.wAFN0UK8055372@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <sys/malloc.h>
 #include <sys/rwlock.h>
 #include <sys/sx.h>
+#include <sys/vmem.h>
 #include <vm/uma.h>
 
 #include <dev/pci/pcivar.h>
@@ -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 <sys/vmem.h>
 #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 *);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811152300.wAFN0UK8055372>