Received: with ECARTIS (v1.0.0; list netdev); Thu, 30 Dec 2004 00:47:49 -0800 (PST) Received: from smtp.knology.net (smtp.knology.net [24.214.63.101]) by oss.sgi.com (8.13.0/8.13.0) with SMTP id iBU8kOk9024573 for ; Thu, 30 Dec 2004 00:46:44 -0800 Received: (qmail 19785 invoked by uid 0); 30 Dec 2004 08:53:07 -0000 Received: from user-69-1-45-93.knology.net (HELO ori.thedillows.org) (69.1.45.93) by smtp8.knology.net with SMTP; 30 Dec 2004 08:53:07 -0000 Received: from ori.thedillows.org (localhost [127.0.0.1]) by ori.thedillows.org (8.13.1/8.13.1) with ESMTP id iBU8mbnl009819; Thu, 30 Dec 2004 03:48:37 -0500 Received: (from root@localhost) by ori.thedillows.org (8.13.1/8.13.1/Submit) id iBU8mb7S009818; Thu, 30 Dec 2004 03:48:37 -0500 Date: Thu, 30 Dec 2004 03:48:37 -0500 To: netdev@oss.sgi.com Cc: linux-kernel@vger.kernel.org, dave@thedillows.org From: David Dillow Subject: [RFC 2.6.10 16/22] typhoon: collect crypto offload capabilities Message-Id: <20041230035000.25@ori.thedillows.org> References: <20041230035000.24@ori.thedillows.org> X-Virus-Scanned: ClamAV 0.80/638/Tue Dec 21 14:41:34 2004 clamav-milter version 0.80j on 127.0.0.1 X-Virus-Status: Clean X-archive-position: 13202 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: dave@thedillows.org Precedence: bulk X-list: netdev # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/12/30 00:56:40-05:00 dave@thedillows.org # Collect some information about the Typhoon's offload capabilities, # and store it for future use. # # Signed-off-by: David Dillow # # drivers/net/typhoon.h # 2004/12/30 00:56:22-05:00 dave@thedillows.org +14 -0 # Add the reply message format for the crypto capability query command. # # Signed-off-by: David Dillow # # drivers/net/typhoon.c # 2004/12/30 00:56:22-05:00 dave@thedillows.org +56 -0 # Collect some information about the Typhoon's offload capabilities, # and store it for future use. # # Signed-off-by: David Dillow # diff -Nru a/drivers/net/typhoon.c b/drivers/net/typhoon.c --- a/drivers/net/typhoon.c 2004-12-30 01:08:58 -05:00 +++ b/drivers/net/typhoon.c 2004-12-30 01:08:58 -05:00 @@ -305,6 +305,12 @@ u16 wol_events; u32 offload; + u16 tx_sa_max; + u16 rx_sa_max; + u16 tx_sa_avail; + u16 rx_sa_avail; + int sa_count; + /* unused stuff (future use) */ int capabilities; struct transmit_ring txHiRing; @@ -2105,6 +2111,53 @@ return 0; } +static inline int +typhoon_ipsec_init(struct typhoon *tp) +{ + struct cmd_desc xp_cmd; + struct resp_desc xp_resp; + struct ipsec_info_desc *info = (struct ipsec_info_desc *) &xp_resp; + u16 last_tx, last_rx, last_cap; + int err; + + last_tx = tp->tx_sa_max; + last_rx = tp->rx_sa_max; + last_cap = tp->capabilities; + + INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_IPSEC_INFO); + err = typhoon_issue_command(tp, 1, &xp_cmd, 1, &xp_resp); + if(err < 0) + goto out; + + /* We're not up yet, so no need to lock this -- we cannot modify + * these fields yet. + */ + tp->tx_sa_avail = tp->tx_sa_max = le16_to_cpu(info->tx_sa_max); + tp->rx_sa_avail = tp->rx_sa_max = le16_to_cpu(info->rx_sa_max); + tp->sa_count = 0; + + /* Typhoon2 was originally going to have variable crypto capabilities, + * subject to registration with 3Com. It appears they have decided + * to just enable 3DES as well. + */ + if(tp->capabilities & TYPHOON_CRYPTO_VARIABLE) { + tp->capabilities &= ~TYPHOON_CRYPTO_VARIABLE; + tp->capabilities |= TYPHOON_CRYPTO_DES | TYPHOON_CRYPTO_3DES; + } + + if(last_tx != tp->tx_sa_max || last_rx != tp->rx_sa_max || + last_cap != tp->capabilities) { + printk(KERN_INFO "%s: IPSEC offload %s%s %d Tx %d Rx\n", + tp->name, + tp->capabilities & TYPHOON_CRYPTO_DES ? "DES " : "", + tp->capabilities & TYPHOON_CRYPTO_3DES ? "3DES" : "", + tp->tx_sa_max, tp->rx_sa_max); + } + +out: + return err; +} + static int typhoon_start_runtime(struct typhoon *tp) { @@ -2127,6 +2180,9 @@ err = -EIO; goto error_out; } + + if(typhoon_ipsec_init(tp)) + goto error_out; INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_MAX_PKT_SIZE); xp_cmd.parm1 = cpu_to_le16(PKT_BUF_SZ); diff -Nru a/drivers/net/typhoon.h b/drivers/net/typhoon.h --- a/drivers/net/typhoon.h 2004-12-30 01:08:58 -05:00 +++ b/drivers/net/typhoon.h 2004-12-30 01:08:58 -05:00 @@ -487,6 +487,20 @@ u32 unused2; } __attribute__ ((packed)); +/* TYPHOON_CMD_READ_IPSEC_INFO response descriptor + */ +struct ipsec_info_desc { + u8 flags; + u8 numDesc; + u16 cmd; + u16 seqNo; + u16 des_enabled; + u16 tx_sa_max; + u16 rx_sa_max; + u16 tx_sa_count; + u16 rx_sa_count; +} __attribute__ ((packed)); + /* TYPHOON_CMD_SET_OFFLOAD_TASKS bits (cmd.parm2 (Tx) & cmd.parm3 (Rx)) * This is all for IPv4. */