Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add a driver for Intel Centrino 7260 and similar wireles...



details:   https://anonhg.NetBSD.org/src/rev/d5ea4c4fc8fc
branches:  trunk
changeset: 336029:d5ea4c4fc8fc
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sat Feb 07 13:20:00 2015 +0000

description:
Add a driver for Intel Centrino 7260 and similar wireless cards.
Supported devices should more or less match ones supported
by the Linux iwlwifi mvm driver.  Sponsored by genua mbh for OpenBSD.

This is probably the world's first Canadian cross device driver: it was
created for OpenBSD by writing and porting a NetBSD driver which was
developed in a rump kernel in Linux userspace.

Note: I don't have access to the hardware anymore, so this version is
not tested and not enabled by default.  While I tried to be careful in
adding the NetBSD bits back, it's probable that there's a snafu or two.
Feel free to send private email in case you have the hardware and there
are issues.

diffstat:

 sys/arch/amd64/conf/GENERIC |     5 +-
 sys/dev/pci/files.pci       |     7 +-
 sys/dev/pci/if_iwm.c        |  6775 +++++++++++++++++++++++++++++++++++++++++++
 sys/dev/pci/if_iwmreg.h     |  5306 +++++++++++++++++++++++++++++++++
 sys/dev/pci/if_iwmvar.h     |   512 +++
 5 files changed, 12602 insertions(+), 3 deletions(-)

diffs (truncated from 12652 to 300 lines):

diff -r 1172c1cabaf2 -r d5ea4c4fc8fc sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC       Sat Feb 07 12:50:25 2015 +0000
+++ b/sys/arch/amd64/conf/GENERIC       Sat Feb 07 13:20:00 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.406 2014/12/19 17:06:31 msaitoh Exp $
+# $NetBSD: GENERIC,v 1.407 2015/02/07 13:20:00 pooka Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.406 $"
+#ident                 "GENERIC-$Revision: 1.407 $"
 
 maxusers       64              # estimated number of users
 
@@ -734,6 +734,7 @@
 ipw*   at pci? dev ? function ?        # Intel PRO/Wireless 2100
 iwi*   at pci? dev ? function ?        # Intel PRO/Wireless 2200BG
 iwn*   at pci? dev ? function ?        # Intel PRO/Wireless 4965AGN
+#iwm*  at pci? dev ? function ?        # Intel Centrino 7260
 ixg*   at pci? dev ? function ?        # Intel 8259x 10 gigabit
 jme*   at pci? dev ? function ?        # JMicron JMC2[56]0 ethernet
 hme*   at pci? dev ? function ?        # Sun Microelectronics STP2002-STQ
diff -r 1172c1cabaf2 -r d5ea4c4fc8fc sys/dev/pci/files.pci
--- a/sys/dev/pci/files.pci     Sat Feb 07 12:50:25 2015 +0000
+++ b/sys/dev/pci/files.pci     Sat Feb 07 13:20:00 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.pci,v 1.372 2014/10/26 18:43:18 tls Exp $
+#      $NetBSD: files.pci,v 1.373 2015/02/07 13:20:00 pooka Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -936,6 +936,11 @@
 attach iwn at pci
 file   dev/pci/if_iwn.c                iwn
 
+# Intel Centrino 7260
+device iwm: ifnet, arp, wlan, firmload
+attach iwm at pci
+file   dev/pci/if_iwm.c                iwm
+
 # Workbit NinjaSCSI-32 controllers
 # device declaration in sys/conf/files
 attach njs at pci with njs_pci
diff -r 1172c1cabaf2 -r d5ea4c4fc8fc sys/dev/pci/if_iwm.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/if_iwm.c      Sat Feb 07 13:20:00 2015 +0000
@@ -0,0 +1,6775 @@
+/*     $NetBSD: if_iwm.c,v 1.1 2015/02/07 13:20:00 pooka Exp $ */
+/*     OpenBSD: if_iwm.c,v 1.3 2015/02/07 07:10:44 phessler Exp        */
+
+/*
+ * Copyright (c) 2014 genua mbh <info%genua.de@localhost>
+ * Copyright (c) 2014 Fixup Software Ltd.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*-
+ * Based on BSD-licensed source modules in the Linux iwlwifi driver,
+ * which were used as the reference documentation for this implementation.
+ *
+ * Driver version we are currently based off of is
+ * Linux 3.14.3 (tag id a2df521e42b1d9a23f620ac79dbfe8655a8391dd)
+ *
+ ***********************************************************************
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2007 - 2013 Intel Corporation. All rights reserved.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless <ilw%linux.intel.com@localhost>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2005 - 2013 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini%free.fr@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.1 2015/02/07 13:20:00 pooka Exp $");
+
+#include <sys/param.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/kmem.h>
+#include <sys/mbuf.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/systm.h>
+
+#include <sys/cpu.h>
+#include <sys/bus.h>
+#include <sys/workqueue.h>
+#include <machine/endian.h>
+#include <machine/intr.h>
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcidevs.h>
+#include <dev/firmload.h>
+
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_types.h>
+#include <net/if_ether.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_amrr.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#define DEVNAME(_s)    device_xname((_s)->sc_dev)
+#define IC2IFP(_ic_)   ((_ic_)->ic_ifp)
+
+#define le16_to_cpup(_a_) (le16toh(*(const uint16_t *)(_a_)))
+#define le32_to_cpup(_a_) (le32toh(*(const uint32_t *)(_a_)))
+
+#ifdef IWM_DEBUG
+#define DPRINTF(x)     do { if (iwm_debug > 0) printf x; } while (0)
+#define DPRINTFN(n, x) do { if (iwm_debug >= (n)) printf x; } while (0)
+int iwm_debug = 1;
+#else
+#define DPRINTF(x)     do { ; } while (0)
+#define DPRINTFN(n, x) do { ; } while (0)
+#endif
+
+#include <dev/pci/if_iwmreg.h>
+#include <dev/pci/if_iwmvar.h>
+
+const uint8_t iwm_nvm_channels[] = {
+       /* 2.4 GHz */
+       1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+       /* 5 GHz */
+       36, 40, 44 , 48, 52, 56, 60, 64,
+       100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144,
+       149, 153, 157, 161, 165
+};
+#define IWM_NUM_2GHZ_CHANNELS  14
+
+#define IWM_NO_5GHZ            1
+
+const struct iwm_rate {
+       uint8_t rate;
+       uint8_t plcp;
+} iwm_rates[] = {
+       {   2,  IWM_RATE_1M_PLCP  },
+       {   4,  IWM_RATE_2M_PLCP  },
+       {  11,  IWM_RATE_5M_PLCP  },
+       {  22,  IWM_RATE_11M_PLCP },
+       {  12,  IWM_RATE_6M_PLCP  },
+       {  18,  IWM_RATE_9M_PLCP  },
+       {  24,  IWM_RATE_12M_PLCP },
+       {  36,  IWM_RATE_18M_PLCP },
+       {  48,  IWM_RATE_24M_PLCP },
+       {  72,  IWM_RATE_36M_PLCP },
+       {  96,  IWM_RATE_48M_PLCP },
+       { 108,  IWM_RATE_54M_PLCP },
+};
+#define IWM_RIDX_CCK   0
+#define IWM_RIDX_OFDM  4
+#define IWM_RIDX_MAX   (__arraycount(iwm_rates)-1)
+#define IWM_RIDX_IS_CCK(_i_) ((_i_) < IWM_RIDX_OFDM)
+#define IWM_RIDX_IS_OFDM(_i_) ((_i_) >= IWM_RIDX_OFDM)
+
+/*
+ * Supported rates for 802.11a/b/g modes (in 500Kbps unit).
+ */
+const struct ieee80211_rateset iwm_rateset_11a =
+       { 8, { 12, 18, 24, 36, 48, 72, 96, 108 } };
+
+const struct ieee80211_rateset iwm_rateset_11b =
+       { 4, { 2, 4, 11, 22 } };
+
+const struct ieee80211_rateset iwm_rateset_11g =
+       { 12, { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 } };
+
+struct iwm_newstate_state {
+       struct work ns_wk;
+       struct ieee80211com *ns_ic;
+       enum ieee80211_state ns_nstate;
+       int ns_arg;
+       int ns_generation;
+};
+
+int    iwm_store_cscheme(struct iwm_softc *, uint8_t *, size_t);
+int    iwm_firmware_store_section(struct iwm_softc *, enum iwm_ucode_type,
+                                       uint8_t *, size_t);
+int    iwm_set_default_calib(struct iwm_softc *, const void *);
+int    iwm_read_firmware(struct iwm_softc *);
+uint32_t iwm_read_prph(struct iwm_softc *, uint32_t);
+void   iwm_write_prph(struct iwm_softc *, uint32_t, uint32_t);
+int    iwm_read_mem(struct iwm_softc *, uint32_t, void *, int);
+int    iwm_write_mem(struct iwm_softc *, uint32_t, const void *, int);
+int    iwm_write_mem32(struct iwm_softc *, uint32_t, uint32_t);
+int    iwm_poll_bit(struct iwm_softc *, int, uint32_t, uint32_t, int);
+int    iwm_nic_lock(struct iwm_softc *);
+void   iwm_nic_unlock(struct iwm_softc *);
+void   iwm_set_bits_mask_prph(struct iwm_softc *, uint32_t, uint32_t,
+                               uint32_t); 
+void   iwm_set_bits_prph(struct iwm_softc *, uint32_t, uint32_t);
+void   iwm_clear_bits_prph(struct iwm_softc *, uint32_t, uint32_t);
+int    iwm_dma_contig_alloc(bus_dma_tag_t, struct iwm_dma_info *,
+                               bus_size_t, bus_size_t);
+void   iwm_dma_contig_free(struct iwm_dma_info *);
+int    iwm_alloc_fwmem(struct iwm_softc *);
+void   iwm_free_fwmem(struct iwm_softc *);
+int    iwm_alloc_sched(struct iwm_softc *);
+void   iwm_free_sched(struct iwm_softc *);
+int    iwm_alloc_kw(struct iwm_softc *);
+void   iwm_free_kw(struct iwm_softc *);
+int    iwm_alloc_ict(struct iwm_softc *);
+void   iwm_free_ict(struct iwm_softc *);
+int    iwm_alloc_rx_ring(struct iwm_softc *, struct iwm_rx_ring *);



Home | Main Index | Thread Index | Old Index