]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
authorDavid S. Miller <davem@davemloft.net>
Tue, 26 Oct 2010 18:32:28 +0000 (11:32 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 Oct 2010 18:32:28 +0000 (11:32 -0700)
96 files changed:
Documentation/networking/phy.txt
drivers/connector/cn_queue.c
drivers/connector/connector.c
drivers/net/atl1c/atl1c.h
drivers/net/atl1c/atl1c_main.c
drivers/net/atlx/atl1.c
drivers/net/atlx/atl1.h
drivers/net/atlx/atlx.c
drivers/net/benet/be_cmds.c
drivers/net/benet/be_cmds.h
drivers/net/benet/be_main.c
drivers/net/bnx2x/bnx2x.h
drivers/net/bnx2x/bnx2x_cmn.c
drivers/net/bnx2x/bnx2x_cmn.h
drivers/net/bnx2x/bnx2x_init_ops.h
drivers/net/bnx2x/bnx2x_link.c
drivers/net/bnx2x/bnx2x_link.h
drivers/net/bnx2x/bnx2x_main.c
drivers/net/can/Kconfig
drivers/net/can/Makefile
drivers/net/can/at91_can.c
drivers/net/can/flexcan.c
drivers/net/can/mcp251x.c
drivers/net/can/pch_can.c [new file with mode: 0644]
drivers/net/can/sja1000/Kconfig
drivers/net/can/sja1000/Makefile
drivers/net/can/sja1000/tscan1.c [new file with mode: 0644]
drivers/net/cxgb3/cxgb3_main.c
drivers/net/cxgb4/cxgb4.h
drivers/net/cxgb4/cxgb4_main.c
drivers/net/cxgb4/sge.c
drivers/net/e1000/e1000_main.c
drivers/net/jme.c
drivers/net/macb.c
drivers/net/mlx4/icm.c
drivers/net/mlx4/icm.h
drivers/net/mlx4/port.c
drivers/net/phy/phy.c
drivers/net/phy/phy_device.c
drivers/net/qlge/qlge.h
drivers/net/qlge/qlge_main.c
drivers/net/qlge/qlge_mpi.c
drivers/net/sgiseeq.c
drivers/net/slhc.c
drivers/net/tokenring/tms380tr.c
drivers/net/typhoon.c
drivers/net/vmxnet3/upt1_defs.h
drivers/net/vmxnet3/vmxnet3_defs.h
drivers/net/vmxnet3/vmxnet3_drv.c
drivers/net/vmxnet3/vmxnet3_ethtool.c
drivers/net/vmxnet3/vmxnet3_int.h
drivers/net/vxge/vxge-config.c
drivers/net/vxge/vxge-config.h
drivers/net/vxge/vxge-ethtool.c
drivers/net/vxge/vxge-main.c
drivers/net/vxge/vxge-main.h
drivers/net/vxge/vxge-traffic.c
drivers/net/vxge/vxge-traffic.h
include/linux/connector.h
include/linux/netdevice.h
include/linux/phy.h
include/net/garp.h
include/net/ip.h
include/net/ip6_tunnel.h
include/net/ipip.h
include/net/net_namespace.h
include/net/sock.h
include/net/xfrm.h
net/802/garp.c
net/802/stp.c
net/8021q/vlan.c
net/core/dev.c
net/core/filter.c
net/core/net-sysfs.c
net/core/net_namespace.c
net/core/pktgen.c
net/core/sock.c
net/core/sysctl_net_core.c
net/ipv4/gre.c
net/ipv4/ip_sockglue.c
net/ipv4/udp.c
net/ipv6/ip6_tunnel.c
net/ipv6/ipv6_sockglue.c
net/ipv6/netfilter/Kconfig
net/ipv6/netfilter/Makefile
net/ipv6/netfilter/nf_conntrack_reasm.c
net/ipv6/raw.c
net/ipv6/tunnel6.c
net/ipv6/udp.c
net/l2tp/l2tp_core.c
net/l2tp/l2tp_core.h
net/l2tp/l2tp_ip.c
net/netfilter/Kconfig
net/netfilter/xt_TPROXY.c
net/netfilter/xt_socket.c
net/netlink/af_netlink.c

index 88bb71b46da4217b8704bf10b8ccae68d1ad832d..9eb1ba52013df53040af34f44b95745a049f8e39 100644 (file)
@@ -177,18 +177,6 @@ Doing it all yourself
  
    A convenience function to print out the PHY status neatly.
 
- int phy_clear_interrupt(struct phy_device *phydev);
- int phy_config_interrupt(struct phy_device *phydev, u32 interrupts);
-   
-   Clear the PHY's interrupt, and configure which ones are allowed,
-   respectively.  Currently only supports all on, or all off.
- int phy_enable_interrupts(struct phy_device *phydev);
- int phy_disable_interrupts(struct phy_device *phydev);
-
-   Functions which enable/disable PHY interrupts, clearing them
-   before and after, respectively.
-
  int phy_start_interrupts(struct phy_device *phydev);
  int phy_stop_interrupts(struct phy_device *phydev);
 
@@ -213,12 +201,6 @@ Doing it all yourself
    Fills the phydev structure with up-to-date information about the current
    settings in the PHY.
 
- void phy_sanitize_settings(struct phy_device *phydev)
-   
-   Resolves differences between currently desired settings, and
-   supported settings for the given PHY device.  Does not make
-   the changes in the hardware, though.
-
  int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
  int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
 
index 210338ea222f38e408d093f2aceaf9e0c539e5bc..81270d221e5ae5aac86b3fb676bc5ede51e9a7f5 100644 (file)
 #include <linux/connector.h>
 #include <linux/delay.h>
 
-
-/*
- * This job is sent to the kevent workqueue.
- * While no event is once sent to any callback, the connector workqueue
- * is not created to avoid a useless waiting kernel task.
- * Once the first event is received, we create this dedicated workqueue which
- * is necessary because the flow of data can be high and we don't want
- * to encumber keventd with that.
- */
-static void cn_queue_create(struct work_struct *work)
-{
-       struct cn_queue_dev *dev;
-
-       dev = container_of(work, struct cn_queue_dev, wq_creation);
-
-       dev->cn_queue = create_singlethread_workqueue(dev->name);
-       /* If we fail, we will use keventd for all following connector jobs */
-       WARN_ON(!dev->cn_queue);
-}
-
-/*
- * Queue a data sent to a callback.
- * If the connector workqueue is already created, we queue the job on it.
- * Otherwise, we queue the job to kevent and queue the connector workqueue
- * creation too.
- */
-int queue_cn_work(struct cn_callback_entry *cbq, struct work_struct *work)
-{
-       struct cn_queue_dev *pdev = cbq->pdev;
-
-       if (likely(pdev->cn_queue))
-               return queue_work(pdev->cn_queue, work);
-
-       /* Don't create the connector workqueue twice */
-       if (atomic_inc_return(&pdev->wq_requested) == 1)
-               schedule_work(&pdev->wq_creation);
-       else
-               atomic_dec(&pdev->wq_requested);
-
-       return schedule_work(work);
-}
-
 void cn_queue_wrapper(struct work_struct *work)
 {
        struct cn_callback_entry *cbq =
@@ -111,11 +69,7 @@ cn_queue_alloc_callback_entry(char *name, struct cb_id *id,
 
 static void cn_queue_free_callback(struct cn_callback_entry *cbq)
 {
-       /* The first jobs have been sent to kevent, flush them too */
-       flush_scheduled_work();
-       if (cbq->pdev->cn_queue)
-               flush_workqueue(cbq->pdev->cn_queue);
-
+       flush_workqueue(cbq->pdev->cn_queue);
        kfree(cbq);
 }
 
@@ -193,11 +147,14 @@ struct cn_queue_dev *cn_queue_alloc_dev(char *name, struct sock *nls)
        atomic_set(&dev->refcnt, 0);
        INIT_LIST_HEAD(&dev->queue_list);
        spin_lock_init(&dev->queue_lock);
-       init_waitqueue_head(&dev->wq_created);
 
        dev->nls = nls;
 
-       INIT_WORK(&dev->wq_creation, cn_queue_create);
+       dev->cn_queue = alloc_ordered_workqueue(dev->name, 0);
+       if (!dev->cn_queue) {
+               kfree(dev);
+               return NULL;
+       }
 
        return dev;
 }
@@ -205,25 +162,9 @@ struct cn_queue_dev *cn_queue_alloc_dev(char *name, struct sock *nls)
 void cn_queue_free_dev(struct cn_queue_dev *dev)
 {
        struct cn_callback_entry *cbq, *n;
-       long timeout;
-       DEFINE_WAIT(wait);
-
-       /* Flush the first pending jobs queued on kevent */
-       flush_scheduled_work();
-
-       /* If the connector workqueue creation is still pending, wait for it */
-       prepare_to_wait(&dev->wq_created, &wait, TASK_UNINTERRUPTIBLE);
-       if (atomic_read(&dev->wq_requested) && !dev->cn_queue) {
-               timeout = schedule_timeout(HZ * 2);
-               if (!timeout && !dev->cn_queue)
-                       WARN_ON(1);
-       }
-       finish_wait(&dev->wq_created, &wait);
 
-       if (dev->cn_queue) {
-               flush_workqueue(dev->cn_queue);
-               destroy_workqueue(dev->cn_queue);
-       }
+       flush_workqueue(dev->cn_queue);
+       destroy_workqueue(dev->cn_queue);
 
        spin_lock_bh(&dev->queue_lock);
        list_for_each_entry_safe(cbq, n, &dev->queue_list, callback_entry)
index 1d48f40342cbfadd6834b5edaf06d39dddabe315..e16c3fa8d2e3e3649a6cab79fb34db9323aae711 100644 (file)
@@ -133,7 +133,8 @@ static int cn_call_callback(struct sk_buff *skb)
                                        __cbq->data.skb == NULL)) {
                                __cbq->data.skb = skb;
 
-                               if (queue_cn_work(__cbq, &__cbq->work))
+                               if (queue_work(dev->cbdev->cn_queue,
+                                              &__cbq->work))
                                        err = 0;
                                else
                                        err = -EINVAL;
@@ -148,13 +149,11 @@ static int cn_call_callback(struct sk_buff *skb)
                                        d->callback = __cbq->data.callback;
                                        d->free = __new_cbq;
 
-                                       __new_cbq->pdev = __cbq->pdev;
-
                                        INIT_WORK(&__new_cbq->work,
                                                        &cn_queue_wrapper);
 
-                                       if (queue_cn_work(__new_cbq,
-                                                   &__new_cbq->work))
+                                       if (queue_work(dev->cbdev->cn_queue,
+                                                      &__new_cbq->work))
                                                err = 0;
                                        else {
                                                kfree(__new_cbq);
index ef4115b897bf8d394b85e4123ca7160c73eaf134..9ab58097fa2e794fe46b8e1547d7bd762153a8f7 100644 (file)
@@ -631,8 +631,6 @@ struct atl1c_adapter {
 extern char atl1c_driver_name[];
 extern char atl1c_driver_version[];
 
-extern int atl1c_up(struct atl1c_adapter *adapter);
-extern void atl1c_down(struct atl1c_adapter *adapter);
 extern void atl1c_reinit_locked(struct atl1c_adapter *adapter);
 extern s32 atl1c_reset_hw(struct atl1c_hw *hw);
 extern void atl1c_set_ethtool_ops(struct net_device *netdev);
index 99ffcf667d1f7cc08287aa20a12f117e52a43432..09b099bfab2b1b75c5dc7e3f0b323393e0124f8a 100644 (file)
@@ -66,6 +66,8 @@ static void atl1c_set_aspm(struct atl1c_hw *hw, bool linkup);
 static void atl1c_setup_mac_ctrl(struct atl1c_adapter *adapter);
 static void atl1c_clean_rx_irq(struct atl1c_adapter *adapter, u8 que,
                   int *work_done, int work_to_do);
+static int atl1c_up(struct atl1c_adapter *adapter);
+static void atl1c_down(struct atl1c_adapter *adapter);
 
 static const u16 atl1c_pay_load_size[] = {
        128, 256, 512, 1024, 2048, 4096,
@@ -2309,7 +2311,7 @@ static int atl1c_request_irq(struct atl1c_adapter *adapter)
        return err;
 }
 
-int atl1c_up(struct atl1c_adapter *adapter)
+static int atl1c_up(struct atl1c_adapter *adapter)
 {
        struct net_device *netdev = adapter->netdev;
        int num;
@@ -2351,7 +2353,7 @@ err_alloc_rx:
        return err;
 }
 
-void atl1c_down(struct atl1c_adapter *adapter)
+static void atl1c_down(struct atl1c_adapter *adapter)
 {
        struct net_device *netdev = adapter->netdev;
 
index dbd27b8e66bdac2f324e6b01fd53ac16cf9d41c9..43579b3b24acce4e23caac9e9ce1d2f2f811af44 100644 (file)
@@ -91,6 +91,8 @@ MODULE_VERSION(ATLX_DRIVER_VERSION);
 /* Temporary hack for merging atl1 and atl2 */
 #include "atlx.c"
 
+static const struct ethtool_ops atl1_ethtool_ops;
+
 /*
  * This is the only thing that needs to be changed to adjust the
  * maximum number of ports that the driver can manage.
@@ -353,7 +355,7 @@ static bool atl1_read_eeprom(struct atl1_hw *hw, u32 offset, u32 *p_value)
  * hw - Struct containing variables accessed by shared code
  * reg_addr - address of the PHY register to read
  */
-s32 atl1_read_phy_reg(struct atl1_hw *hw, u16 reg_addr, u16 *phy_data)
+static s32 atl1_read_phy_reg(struct atl1_hw *hw, u16 reg_addr, u16 *phy_data)
 {
        u32 val;
        int i;
@@ -553,7 +555,7 @@ static s32 atl1_read_mac_addr(struct atl1_hw *hw)
  *          1. calcu 32bit CRC for multicast address
  *          2. reverse crc with MSB to LSB
  */
-u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr)
+static u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr)
 {
        u32 crc32, value = 0;
        int i;
@@ -570,7 +572,7 @@ u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr)
  * hw - Struct containing variables accessed by shared code
  * hash_value - Multicast address hash value
  */
-void atl1_hash_set(struct atl1_hw *hw, u32 hash_value)
+static void atl1_hash_set(struct atl1_hw *hw, u32 hash_value)
 {
        u32 hash_bit, hash_reg;
        u32 mta;
@@ -914,7 +916,7 @@ static s32 atl1_get_speed_and_duplex(struct atl1_hw *hw, u16 *speed, u16 *duplex
        return 0;
 }
 
-void atl1_set_mac_addr(struct atl1_hw *hw)
+static void atl1_set_mac_addr(struct atl1_hw *hw)
 {
        u32 value;
        /*
@@ -3658,7 +3660,7 @@ static int atl1_nway_reset(struct net_device *netdev)
        return 0;
 }
 
-const struct ethtool_ops atl1_ethtool_ops = {
+static const struct ethtool_ops atl1_ethtool_ops = {
        .get_settings           = atl1_get_settings,
        .set_settings           = atl1_set_settings,
        .get_drvinfo            = atl1_get_drvinfo,
index 9c0ddb273ac81a38c0de24fa315c4c9d5519cde4..68de8cbfb3ec05da6244f1225ea23b9cef58b19c 100644 (file)
@@ -56,16 +56,13 @@ struct atl1_adapter;
 struct atl1_hw;
 
 /* function prototypes needed by multiple files */
-u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr);
-void atl1_hash_set(struct atl1_hw *hw, u32 hash_value);
-s32 atl1_read_phy_reg(struct atl1_hw *hw, u16 reg_addr, u16 *phy_data);
-void atl1_set_mac_addr(struct atl1_hw *hw);
+static u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr);
+static void atl1_hash_set(struct atl1_hw *hw, u32 hash_value);
+static void atl1_set_mac_addr(struct atl1_hw *hw);
 static int atl1_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
        int cmd);
 static u32 atl1_check_link(struct atl1_adapter *adapter);
 
-extern const struct ethtool_ops atl1_ethtool_ops;
-
 /* hardware definitions specific to L1 */
 
 /* Block IDLE Status Register */
index f979ea2d6d3cd7cd6c080bfbd57cc8159b0d3279..afb7f7dd1bb133901aab8f71c30bc2d86ef35fd7 100644 (file)
 
 #include "atlx.h"
 
+static s32 atlx_read_phy_reg(struct atl1_hw *hw, u16 reg_addr, u16 *phy_data);
+static u32 atlx_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr);
+static void atlx_set_mac_addr(struct atl1_hw *hw);
+
 static struct atlx_spi_flash_dev flash_table[] = {
 /*     MFR_NAME  WRSR  READ  PRGM  WREN  WRDI  RDSR  RDID  SEC_ERS CHIP_ERS */
        {"Atmel", 0x00, 0x03, 0x02, 0x06, 0x04, 0x05, 0x15, 0x52,   0x62},
index 1e7f305ed00b310ea91aa73b40620f37794b739e..36eca1ce75d4e29a4c41bbf285931ce003a6a92a 100644 (file)
@@ -1471,42 +1471,6 @@ err:
        return status;
 }
 
-/* Uses sync mcc */
-int be_cmd_read_port_type(struct be_adapter *adapter, u32 port,
-                               u8 *connector)
-{
-       struct be_mcc_wrb *wrb;
-       struct be_cmd_req_port_type *req;
-       int status;
-
-       spin_lock_bh(&adapter->mcc_lock);
-
-       wrb = wrb_from_mccq(adapter);
-       if (!wrb) {
-               status = -EBUSY;
-               goto err;
-       }
-       req = embedded_payload(wrb);
-
-       be_wrb_hdr_prepare(wrb, sizeof(struct be_cmd_resp_port_type), true, 0,
-                       OPCODE_COMMON_READ_TRANSRECV_DATA);
-
-       be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
-               OPCODE_COMMON_READ_TRANSRECV_DATA, sizeof(*req));
-
-       req->port = cpu_to_le32(port);
-       req->page_num = cpu_to_le32(TR_PAGE_A0);
-       status = be_mcc_notify_wait(adapter);
-       if (!status) {
-               struct be_cmd_resp_port_type *resp = embedded_payload(wrb);
-                       *connector = resp->data.connector;
-       }
-
-err:
-       spin_unlock_bh(&adapter->mcc_lock);
-       return status;
-}
-
 int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
                        u32 flash_type, u32 flash_opcode, u32 buf_size)
 {
index c7f6cdfe1c73df85bc4faf251e05b19dd6602791..8469ff061f30e092f9ef5386114b4ce2ec595a2b 100644 (file)
@@ -1022,8 +1022,6 @@ extern int be_cmd_set_beacon_state(struct be_adapter *adapter,
                        u8 port_num, u8 beacon, u8 status, u8 state);
 extern int be_cmd_get_beacon_state(struct be_adapter *adapter,
                        u8 port_num, u32 *state);
-extern int be_cmd_read_port_type(struct be_adapter *adapter, u32 port,
-                                       u8 *connector);
 extern int be_cmd_write_flashrom(struct be_adapter *adapter,
                        struct be_dma_mem *cmd, u32 flash_oper,
                        u32 flash_opcode, u32 buf_size);
index 45b1f6635282f8cc3bb07098f92d119b4e54f16e..6b80a06eb3a7e6acd919f31f20d5cbd51ffee31d 100644 (file)
@@ -849,20 +849,16 @@ static void be_rx_stats_update(struct be_rx_obj *rxo,
                stats->rx_mcast_pkts++;
 }
 
-static inline bool do_pkt_csum(struct be_eth_rx_compl *rxcp, bool cso)
+static inline bool csum_passed(struct be_eth_rx_compl *rxcp)
 {
-       u8 l4_cksm, ip_version, ipcksm, tcpf = 0, udpf = 0, ipv6_chk;
+       u8 l4_cksm, ipv6, ipcksm;
 
        l4_cksm = AMAP_GET_BITS(struct amap_eth_rx_compl, l4_cksm, rxcp);
        ipcksm = AMAP_GET_BITS(struct amap_eth_rx_compl, ipcksm, rxcp);
-       ip_version = AMAP_GET_BITS(struct amap_eth_rx_compl, ip_version, rxcp);
-       if (ip_version) {
-               tcpf = AMAP_GET_BITS(struct amap_eth_rx_compl, tcpf, rxcp);
-               udpf = AMAP_GET_BITS(struct amap_eth_rx_compl, udpf, rxcp);
-       }
-       ipv6_chk = (ip_version && (tcpf || udpf));
+       ipv6 = AMAP_GET_BITS(struct amap_eth_rx_compl, ip_version, rxcp);
 
-       return ((l4_cksm && ipv6_chk && ipcksm) && cso) ? false : true;
+       /* Ignore ipcksm for ipv6 pkts */
+       return l4_cksm && (ipcksm || ipv6);
 }
 
 static struct be_rx_page_info *
@@ -1017,10 +1013,10 @@ static void be_rx_compl_process(struct be_adapter *adapter,
 
        skb_fill_rx_data(adapter, rxo, skb, rxcp, num_rcvd);
 
-       if (do_pkt_csum(rxcp, adapter->rx_csum))
-               skb_checksum_none_assert(skb);
-       else
+       if (likely(adapter->rx_csum && csum_passed(rxcp)))
                skb->ip_summed = CHECKSUM_UNNECESSARY;
+       else
+               skb_checksum_none_assert(skb);
 
        skb->truesize = skb->len + sizeof(struct sk_buff);
        skb->protocol = eth_type_trans(skb, adapter->netdev);
@@ -1674,7 +1670,7 @@ static inline bool do_gro(struct be_adapter *adapter, struct be_rx_obj *rxo,
        return (tcp_frame && !err) ? true : false;
 }
 
-int be_poll_rx(struct napi_struct *napi, int budget)
+static int be_poll_rx(struct napi_struct *napi, int budget)
 {
        struct be_eq_obj *rx_eq = container_of(napi, struct be_eq_obj, napi);
        struct be_rx_obj *rxo = container_of(rx_eq, struct be_rx_obj, rx_eq);
@@ -2299,9 +2295,6 @@ static int be_clear(struct be_adapter *adapter)
 
 
 #define FW_FILE_HDR_SIGN       "ServerEngines Corp. "
-char flash_cookie[2][16] =     {"*** SE FLAS",
-                               "H DIRECTORY *** "};
-
 static bool be_flash_redboot(struct be_adapter *adapter,
                        const u8 *p, u32 img_start, int image_size,
                        int hdr_size)
@@ -2559,7 +2552,6 @@ static void be_netdev_init(struct net_device *netdev)
        netif_napi_add(netdev, &adapter->tx_eq.napi, be_poll_tx_mcc,
                BE_NAPI_WEIGHT);
 
-       netif_carrier_off(netdev);
        netif_stop_queue(netdev);
 }
 
@@ -2868,6 +2860,7 @@ static int __devinit be_probe(struct pci_dev *pdev,
        status = register_netdev(netdev);
        if (status != 0)
                goto unsetup;
+       netif_carrier_off(netdev);
 
        dev_info(&pdev->dev, "%s port %d\n", nic_name(pdev), adapter->port_num);
        return 0;
index 9571ecf48f35b11a44e6cb6b6262fa8d3c4fb5b7..9eea225decaf724e7d88243fc8c462c62020f81e 100644 (file)
@@ -1288,15 +1288,11 @@ struct bnx2x_func_init_params {
 
 #define WAIT_RAMROD_POLL       0x01
 #define WAIT_RAMROD_COMMON     0x02
-int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
-                            int *state_p, int flags);
 
 /* dmae */
 void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32);
 void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
                      u32 len32);
-void bnx2x_write_dmae_phys_len(struct bnx2x *bp, dma_addr_t phys_addr,
-                              u32 addr, u32 len);
 void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx);
 u32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type);
 u32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode);
@@ -1307,7 +1303,6 @@ int bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port);
 int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
 int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
 u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param);
-void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val);
 
 void bnx2x_calc_fc_adv(struct bnx2x *bp);
 int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
index bc5837514074d410fb740d57dbe90350376dc11b..459614d2d7bcfff471f08f2866a1cc667a272a76 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "bnx2x_init.h"
 
+static int bnx2x_setup_irqs(struct bnx2x *bp);
 
 /* free skb in the packet ring at pos idx
  * return idx of last bd freed
@@ -2187,7 +2188,7 @@ int bnx2x_change_mac_addr(struct net_device *dev, void *p)
 }
 
 
-int bnx2x_setup_irqs(struct bnx2x *bp)
+static int bnx2x_setup_irqs(struct bnx2x *bp)
 {
        int rc = 0;
        if (bp->flags & USING_MSIX_FLAG) {
index 5bfe0ab1d2d4d71cf1f801149f40de07b5f9ffad..6b28739c53028f60d5b2883a8abee0b878cb19ca 100644 (file)
@@ -116,13 +116,6 @@ void bnx2x_setup_cnic_irq_info(struct bnx2x *bp);
  */
 void bnx2x_int_enable(struct bnx2x *bp);
 
-/**
- * Disable HW interrupts.
- *
- * @param bp
- */
-void bnx2x_int_disable(struct bnx2x *bp);
-
 /**
  * Disable interrupts. This function ensures that there are no
  * ISRs or SP DPCs (sp_task) are running after it returns.
@@ -191,17 +184,6 @@ void bnx2x_free_mem(struct bnx2x *bp);
 int bnx2x_setup_client(struct bnx2x *bp, struct bnx2x_fastpath *fp,
                       int is_leading);
 
-/**
- * Bring down an eth client.
- *
- * @param bp
- * @param p
- *
- * @return int
- */
-int bnx2x_stop_fw_client(struct bnx2x *bp,
-                        struct bnx2x_client_ramrod_params *p);
-
 /**
  * Set number of queues according to mode
  *
@@ -250,34 +232,6 @@ int bnx2x_release_hw_lock(struct bnx2x *bp, u32 resource);
  */
 void bnx2x_set_eth_mac(struct bnx2x *bp, int set);
 
-#ifdef BCM_CNIC
-/**
- * Set iSCSI MAC(s) at the next enties in the CAM after the ETH
- * MAC(s). The function will wait until the ramrod completion
- * returns.
- *
- * @param bp driver handle
- * @param set set or clear the CAM entry
- *
- * @return 0 if cussess, -ENODEV if ramrod doesn't return.
- */
-int bnx2x_set_iscsi_eth_mac_addr(struct bnx2x *bp, int set);
-#endif
-
-/**
- * Initialize status block in FW and HW
- *
- * @param bp driver handle
- * @param dma_addr_t mapping
- * @param int sb_id
- * @param int vfid
- * @param u8 vf_valid
- * @param int fw_sb_id
- * @param int igu_sb_id
- */
-void bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid,
-                         u8 vf_valid, int fw_sb_id, int igu_sb_id);
-
 /**
  * Set MAC filtering configurations.
  *
@@ -326,7 +280,6 @@ void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe);
  * @return int
  */
 int bnx2x_func_start(struct bnx2x *bp);
-int bnx2x_func_stop(struct bnx2x *bp);
 
 /**
  * Prepare ILT configurations according to current driver
@@ -395,14 +348,6 @@ int bnx2x_enable_msix(struct bnx2x *bp);
  */
 int bnx2x_enable_msi(struct bnx2x *bp);
 
-/**
- * Request IRQ vectors from OS.
- *
- * @param bp
- *
- * @return int
- */
-int bnx2x_setup_irqs(struct bnx2x *bp);
 /**
  * NAPI callback
  *
index e65de784182c72e9e1395086b08b569ee5823328..a306b0e46b613417c630e79398c5f8250204195d 100644 (file)
@@ -16,7 +16,9 @@
 #define BNX2X_INIT_OPS_H
 
 static int bnx2x_gunzip(struct bnx2x *bp, const u8 *zbuf, int len);
-
+static void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val);
+static void bnx2x_write_dmae_phys_len(struct bnx2x *bp, dma_addr_t phys_addr,
+                                     u32 addr, u32 len);
 
 static void bnx2x_init_str_wr(struct bnx2x *bp, u32 addr, const u32 *data,
                              u32 len)
@@ -589,7 +591,7 @@ static int bnx2x_ilt_client_mem_op(struct bnx2x *bp, int cli_num, u8 memop)
        return rc;
 }
 
-int bnx2x_ilt_mem_op(struct bnx2x *bp, u8 memop)
+static int bnx2x_ilt_mem_op(struct bnx2x *bp, u8 memop)
 {
        int rc = bnx2x_ilt_client_mem_op(bp, ILT_CLIENT_CDU, memop);
        if (!rc)
@@ -635,7 +637,7 @@ static void bnx2x_ilt_line_init_op(struct bnx2x *bp, struct bnx2x_ilt *ilt,
        }
 }
 
-void bnx2x_ilt_boundry_init_op(struct bnx2x *bp,
+static void bnx2x_ilt_boundry_init_op(struct bnx2x *bp,
                                      struct ilt_client_info *ilt_cli,
                                      u32 ilt_start, u8 initop)
 {
@@ -688,8 +690,10 @@ void bnx2x_ilt_boundry_init_op(struct bnx2x *bp,
        }
 }
 
-void bnx2x_ilt_client_init_op_ilt(struct bnx2x *bp, struct bnx2x_ilt *ilt,
-                                 struct ilt_client_info *ilt_cli, u8 initop)
+static void bnx2x_ilt_client_init_op_ilt(struct bnx2x *bp,
+                                        struct bnx2x_ilt *ilt,
+                                        struct ilt_client_info *ilt_cli,
+                                        u8 initop)
 {
        int i;
 
@@ -703,8 +707,8 @@ void bnx2x_ilt_client_init_op_ilt(struct bnx2x *bp, struct bnx2x_ilt *ilt,
        bnx2x_ilt_boundry_init_op(bp, ilt_cli, ilt->start_line, initop);
 }
 
-void bnx2x_ilt_client_init_op(struct bnx2x *bp,
-                             struct ilt_client_info *ilt_cli, u8 initop)
+static void bnx2x_ilt_client_init_op(struct bnx2x *bp,
+                                    struct ilt_client_info *ilt_cli, u8 initop)
 {
        struct bnx2x_ilt *ilt = BP_ILT(bp);
 
@@ -720,7 +724,7 @@ static void bnx2x_ilt_client_id_init_op(struct bnx2x *bp,
        bnx2x_ilt_client_init_op(bp, ilt_cli, initop);
 }
 
-void bnx2x_ilt_init_op(struct bnx2x *bp, u8 initop)
+static void bnx2x_ilt_init_op(struct bnx2x *bp, u8 initop)
 {
        bnx2x_ilt_client_id_init_op(bp, ILT_CLIENT_CDU, initop);
        bnx2x_ilt_client_id_init_op(bp, ILT_CLIENT_QM, initop);
@@ -752,7 +756,7 @@ static void bnx2x_ilt_init_client_psz(struct bnx2x *bp, int cli_num,
  * called during init common stage, ilt clients should be initialized
  * prioir to calling this function
  */
-void bnx2x_ilt_init_page_size(struct bnx2x *bp, u8 initop)
+static void bnx2x_ilt_init_page_size(struct bnx2x *bp, u8 initop)
 {
        bnx2x_ilt_init_client_psz(bp, ILT_CLIENT_CDU,
                                  PXP2_REG_RQ_CDU_P_SIZE, initop);
@@ -772,8 +776,8 @@ void bnx2x_ilt_init_page_size(struct bnx2x *bp, u8 initop)
 #define QM_INIT(cid_cnt)       (cid_cnt > QM_INIT_MIN_CID_COUNT)
 
 /* called during init port stage */
-void bnx2x_qm_init_cid_count(struct bnx2x *bp, int qm_cid_count,
-                            u8 initop)
+static void bnx2x_qm_init_cid_count(struct bnx2x *bp, int qm_cid_count,
+                                   u8 initop)
 {
        int port = BP_PORT(bp);
 
@@ -814,8 +818,8 @@ static void bnx2x_qm_set_ptr_table(struct bnx2x *bp, int qm_cid_count)
 }
 
 /* called during init common stage */
-void bnx2x_qm_init_ptr_table(struct bnx2x *bp, int qm_cid_count,
-                            u8 initop)
+static void bnx2x_qm_init_ptr_table(struct bnx2x *bp, int qm_cid_count,
+                                   u8 initop)
 {
        if (!QM_INIT(qm_cid_count))
                return;
@@ -836,8 +840,8 @@ void bnx2x_qm_init_ptr_table(struct bnx2x *bp, int qm_cid_count,
 ****************************************************************************/
 
 /* called during init func stage */
-void bnx2x_src_init_t2(struct bnx2x *bp, struct src_ent *t2,
-                      dma_addr_t t2_mapping, int src_cid_count)
+static void bnx2x_src_init_t2(struct bnx2x *bp, struct src_ent *t2,
+                             dma_addr_t t2_mapping, int src_cid_count)
 {
        int i;
        int port = BP_PORT(bp);
index 3e99bf9c42b9a83ae18437538f42322e38413d28..2326774df843841315d783dfa6c53a073a2ef4b5 100644 (file)
                (_bank + (_addr & 0xf)), \
                _val)
 
+static u8 bnx2x_cl45_read(struct bnx2x *bp, struct bnx2x_phy *phy,
+                         u8 devad, u16 reg, u16 *ret_val);
+
+static u8 bnx2x_cl45_write(struct bnx2x *bp, struct bnx2x_phy *phy,
+                          u8 devad, u16 reg, u16 val);
+
 static u32 bnx2x_bits_en(struct bnx2x *bp, u32 reg, u32 bits)
 {
        u32 val = REG_RD(bp, reg);
@@ -594,7 +600,7 @@ static u8 bnx2x_bmac2_enable(struct link_params *params,
        return 0;
 }
 
-u8 bnx2x_bmac_enable(struct link_params *params,
+static u8 bnx2x_bmac_enable(struct link_params *params,
                            struct link_vars *vars,
                            u8 is_lb)
 {
@@ -2537,122 +2543,6 @@ static void bnx2x_set_xgxs_loopback(struct bnx2x_phy *phy,
        }
 }
 
-/*
- *------------------------------------------------------------------------
- * bnx2x_override_led_value -
- *
- * Override the led value of the requested led
- *
- *------------------------------------------------------------------------
- */
-u8 bnx2x_override_led_value(struct bnx2x *bp, u8 port,
-                         u32 led_idx, u32 value)
-{
-       u32 reg_val;
-
-       /* If port 0 then use EMAC0, else use EMAC1*/
-       u32 emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0;
-
-       DP(NETIF_MSG_LINK,
-                "bnx2x_override_led_value() port %x led_idx %d value %d\n",
-                port, led_idx, value);
-
-       switch (led_idx) {
-       case 0: /* 10MB led */
-               /* Read the current value of the LED register in
-               the EMAC block */
-               reg_val = REG_RD(bp, emac_base + EMAC_REG_EMAC_LED);
-               /* Set the OVERRIDE bit to 1 */
-               reg_val |= EMAC_LED_OVERRIDE;
-               /* If value is 1, set the 10M_OVERRIDE bit,
-               otherwise reset it.*/
-               reg_val = (value == 1) ? (reg_val | EMAC_LED_10MB_OVERRIDE) :
-                       (reg_val & ~EMAC_LED_10MB_OVERRIDE);
-               REG_WR(bp, emac_base + EMAC_REG_EMAC_LED, reg_val);
-               break;
-       case 1: /*100MB led    */
-               /*Read the current value of the LED register in
-               the EMAC block */
-               reg_val = REG_RD(bp, emac_base + EMAC_REG_EMAC_LED);
-               /*  Set the OVERRIDE bit to 1 */
-               reg_val |= EMAC_LED_OVERRIDE;
-               /*  If value is 1, set the 100M_OVERRIDE bit,
-               otherwise reset it.*/
-               reg_val = (value == 1) ? (reg_val | EMAC_LED_100MB_OVERRIDE) :
-                       (reg_val & ~EMAC_LED_100MB_OVERRIDE);
-               REG_WR(bp, emac_base + EMAC_REG_EMAC_LED, reg_val);
-               break;
-       case 2: /* 1000MB led */
-               /* Read the current value of the LED register in the
-               EMAC block */
-               reg_val = REG_RD(bp, emac_base + EMAC_REG_EMAC_LED);
-               /* Set the OVERRIDE bit to 1 */
-               reg_val |= EMAC_LED_OVERRIDE;
-               /* If value is 1, set the 1000M_OVERRIDE bit, otherwise
-               reset it. */
-               reg_val = (value == 1) ? (reg_val | EMAC_LED_1000MB_OVERRIDE) :
-                       (reg_val & ~EMAC_LED_1000MB_OVERRIDE);
-               REG_WR(bp, emac_base + EMAC_REG_EMAC_LED, reg_val);
-               break;
-       case 3: /* 2500MB led */
-               /*  Read the current value of the LED register in the
-               EMAC block*/
-               reg_val = REG_RD(bp, emac_base + EMAC_REG_EMAC_LED);
-               /* Set the OVERRIDE bit to 1 */
-               reg_val |= EMAC_LED_OVERRIDE;
-               /*  If value is 1, set the 2500M_OVERRIDE bit, otherwise
-               reset it.*/
-               reg_val = (value == 1) ? (reg_val | EMAC_LED_2500MB_OVERRIDE) :
-                       (reg_val & ~EMAC_LED_2500MB_OVERRIDE);
-               REG_WR(bp, emac_base + EMAC_REG_EMAC_LED, reg_val);
-               break;
-       case 4: /*10G led */
-               if (port == 0) {
-                       REG_WR(bp, NIG_REG_LED_10G_P0,
-                                   value);
-               } else {
-                       REG_WR(bp, NIG_REG_LED_10G_P1,
-                                   value);
-               }
-               break;
-       case 5: /* TRAFFIC led */
-               /* Find if the traffic control is via BMAC or EMAC */
-               if (port == 0)
-                       reg_val = REG_RD(bp, NIG_REG_NIG_EMAC0_EN);
-               else
-                       reg_val = REG_RD(bp, NIG_REG_NIG_EMAC1_EN);
-
-               /*  Override the traffic led in the EMAC:*/
-               if (reg_val == 1) {
-                       /* Read the current value of the LED register in
-                       the EMAC block */
-                       reg_val = REG_RD(bp, emac_base +
-                                            EMAC_REG_EMAC_LED);
-                       /* Set the TRAFFIC_OVERRIDE bit to 1 */
-                       reg_val |= EMAC_LED_OVERRIDE;
-                       /* If value is 1, set the TRAFFIC bit, otherwise
-                       reset it.*/
-                       reg_val = (value == 1) ? (reg_val | EMAC_LED_TRAFFIC) :
-                               (reg_val & ~EMAC_LED_TRAFFIC);
-                       REG_WR(bp, emac_base + EMAC_REG_EMAC_LED, reg_val);
-               } else { /* Override the traffic led in the BMAC: */
-                       REG_WR(bp, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
-                                  + port*4, 1);
-                       REG_WR(bp, NIG_REG_LED_CONTROL_TRAFFIC_P0 + port*4,
-                                   value);
-               }
-               break;
-       default:
-               DP(NETIF_MSG_LINK,
-                        "bnx2x_override_led_value() unknown led index %d "
-                        "(should be 0-5)\n", led_idx);
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-
 u8 bnx2x_set_led(struct link_params *params,
                 struct link_vars *vars, u8 mode, u32 speed)
 {
@@ -4099,9 +3989,9 @@ static u8 bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy *phy,
        return -EINVAL;
 }
 
-u8 bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy,
-                               struct link_params *params, u16 addr,
-                                    u8 byte_cnt, u8 *o_buf)
+static u8 bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy,
+                                      struct link_params *params, u16 addr,
+                                      u8 byte_cnt, u8 *o_buf)
 {
        if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726)
                return bnx2x_8726_read_sfp_module_eeprom(phy, params, addr,
@@ -6819,13 +6709,6 @@ u8 bnx2x_phy_probe(struct link_params *params)
        return 0;
 }
 
-u32 bnx2x_supported_attr(struct link_params *params, u8 phy_idx)
-{
-       if (phy_idx < params->num_phys)
-               return params->phy[phy_idx].supported;
-       return 0;
-}
-
 static void set_phy_vars(struct link_params *params)
 {
        struct bnx2x *bp = params->bp;
index 58a4c719927633a0a525546238b271c8eaf08a85..171abf8097ee3e509ddc8fbe384d8be1087f2562 100644 (file)
@@ -279,12 +279,6 @@ u8 bnx2x_phy_read(struct link_params *params, u8 phy_addr,
 
 u8 bnx2x_phy_write(struct link_params *params, u8 phy_addr,
                   u8 devad, u16 reg, u16 val);
-
-u8 bnx2x_cl45_read(struct bnx2x *bp, struct bnx2x_phy *phy,
-                  u8 devad, u16 reg, u16 *ret_val);
-
-u8 bnx2x_cl45_write(struct bnx2x *bp, struct bnx2x_phy *phy,
-                   u8 devad, u16 reg, u16 val);
 /* Reads the link_status from the shmem,
    and update the link vars accordingly */
 void bnx2x_link_status_update(struct link_params *input,
@@ -304,8 +298,6 @@ u8 bnx2x_set_led(struct link_params *params, struct link_vars *vars,
 #define LED_MODE_OPER                  2
 #define LED_MODE_FRONT_PANEL_OFF       3
 
-u8 bnx2x_override_led_value(struct bnx2x *bp, u8 port, u32 led_idx, u32 value);
-
 /* bnx2x_handle_module_detect_int should be called upon module detection
    interrupt */
 void bnx2x_handle_module_detect_int(struct link_params *params);
@@ -325,19 +317,12 @@ void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port);
 /* Reset the external of SFX7101 */
 void bnx2x_sfx7101_sp_sw_reset(struct bnx2x *bp, struct bnx2x_phy *phy);
 
-u8 bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy,
-                               struct link_params *params, u16 addr,
-                             u8 byte_cnt, u8 *o_buf);
-
 void bnx2x_hw_reset_phy(struct link_params *params);
 
 /* Checks if HW lock is required for this phy/board type */
 u8 bnx2x_hw_lock_required(struct bnx2x *bp, u32 shmem_base,
                          u32 shmem2_base);
 
-/* Returns the aggregative supported attributes of the phys on board */
-u32 bnx2x_supported_attr(struct link_params *params, u8 phy_idx);
-
 /* Check swap bit and adjust PHY order */
 u32 bnx2x_phy_selection(struct link_params *params);
 
index ff99a2fc04267b6aef6d926cbc5483d12fbb2635..e9ad16f00b56755847eb887a898c999ef2c08c04 100644 (file)
@@ -403,7 +403,7 @@ static inline void storm_memset_hc_disable(struct bnx2x *bp, u8 port,
 /* used only at init
  * locking is done by mcp
  */
-void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val)
+static void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val)
 {
        pci_write_config_dword(bp->pdev, PCICFG_GRC_ADDRESS, addr);
        pci_write_config_dword(bp->pdev, PCICFG_GRC_DATA, val);
@@ -429,7 +429,8 @@ static u32 bnx2x_reg_rd_ind(struct bnx2x *bp, u32 addr)
 #define DMAE_DP_DST_PCI                "pci dst_addr [%x:%08x]"
 #define DMAE_DP_DST_NONE       "dst_addr [none]"
 
-void bnx2x_dp_dmae(struct bnx2x *bp, struct dmae_command *dmae, int msglvl)
+static void bnx2x_dp_dmae(struct bnx2x *bp, struct dmae_command *dmae,
+                         int msglvl)
 {
        u32 src_type = dmae->opcode & DMAE_COMMAND_SRC;
 
@@ -551,8 +552,9 @@ u32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type,
        return opcode;
 }
 
-void bnx2x_prep_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae,
-                              u8 src_type, u8 dst_type)
+static void bnx2x_prep_dmae_with_comp(struct bnx2x *bp,
+                                     struct dmae_command *dmae,
+                                     u8 src_type, u8 dst_type)
 {
        memset(dmae, 0, sizeof(struct dmae_command));
 
@@ -567,7 +569,8 @@ void bnx2x_prep_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae,
 }
 
 /* issue a dmae command over the init-channel and wailt for completion */
-int bnx2x_issue_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae)
+static int bnx2x_issue_dmae_with_comp(struct bnx2x *bp,
+                                     struct dmae_command *dmae)
 {
        u32 *wb_comp = bnx2x_sp(bp, wb_comp);
        int cnt = CHIP_REV_IS_SLOW(bp) ? (400000) : 40;
@@ -674,8 +677,8 @@ void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32)
        bnx2x_issue_dmae_with_comp(bp, &dmae);
 }
 
-void bnx2x_write_dmae_phys_len(struct bnx2x *bp, dma_addr_t phys_addr,
-                              u32 addr, u32 len)
+static void bnx2x_write_dmae_phys_len(struct bnx2x *bp, dma_addr_t phys_addr,
+                                     u32 addr, u32 len)
 {
        int dmae_wr_max = DMAE_LEN32_WR_MAX(bp);
        int offset = 0;
@@ -1267,7 +1270,7 @@ static void bnx2x_igu_int_disable(struct bnx2x *bp)
                BNX2X_ERR("BUG! proper val not read from IGU!\n");
 }
 
-void bnx2x_int_disable(struct bnx2x *bp)
+static void bnx2x_int_disable(struct bnx2x *bp)
 {
        if (bp->common.int_block == INT_BLOCK_HC)
                bnx2x_hc_int_disable(bp);
@@ -2236,7 +2239,7 @@ u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param)
 }
 
 /* must be called under rtnl_lock */
-void bnx2x_rxq_set_mac_filters(struct bnx2x *bp, u16 cl_id, u32 filters)
+static void bnx2x_rxq_set_mac_filters(struct bnx2x *bp, u16 cl_id, u32 filters)
 {
        u32 mask = (1 << cl_id);
 
@@ -2303,7 +2306,7 @@ void bnx2x_rxq_set_mac_filters(struct bnx2x *bp, u16 cl_id, u32 filters)
                bp->mac_filters.unmatched_unicast & ~mask;
 }
 
-void bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p)
+static void bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p)
 {
        struct tstorm_eth_function_common_config tcfg = {0};
        u16 rss_flgs;
@@ -2460,7 +2463,7 @@ static void bnx2x_pf_tx_cl_prep(struct bnx2x *bp,
        txq_init->hc_rate = bp->tx_ticks ? (1000000 / bp->tx_ticks) : 0;
 }
 
-void bnx2x_pf_init(struct bnx2x *bp)
+static void bnx2x_pf_init(struct bnx2x *bp)
 {
        struct bnx2x_func_init_params func_init = {0};
        struct bnx2x_rss_params rss = {0};
@@ -3928,7 +3931,7 @@ void bnx2x_setup_ndsb_state_machine(struct hc_status_block_sm *hc_sm,
        hc_sm->time_to_expire = 0xFFFFFFFF;
 }
 
-void bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid,
+static void bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid,
                          u8 vf_valid, int fw_sb_id, int igu_sb_id)
 {
        int igu_seg_id;
@@ -6021,6 +6024,9 @@ alloc_mem_err:
 /*
  * Init service functions
  */
+static int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
+                            int *state_p, int flags);
+
 int bnx2x_func_start(struct bnx2x *bp)
 {
        bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_FUNCTION_START, 0, 0, 0, 1);
@@ -6030,7 +6036,7 @@ int bnx2x_func_start(struct bnx2x *bp)
                                 WAIT_RAMROD_COMMON);
 }
 
-int bnx2x_func_stop(struct bnx2x *bp)
+static int bnx2x_func_stop(struct bnx2x *bp)
 {
        bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_FUNCTION_STOP, 0, 0, 0, 1);
 
@@ -6103,8 +6109,8 @@ static void bnx2x_set_mac_addr_gen(struct bnx2x *bp, int set, u8 *mac,
        bnx2x_wait_ramrod(bp, 0, 0, &bp->set_mac_pending, ramrod_flags);
 }
 
-int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
-                     int *state_p, int flags)
+static int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
+                            int *state_p, int flags)
 {
        /* can take a while if any port is running */
        int cnt = 5000;
@@ -6154,7 +6160,7 @@ int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
        return -EBUSY;
 }
 
-u8 bnx2x_e1h_cam_offset(struct bnx2x *bp, u8 rel_offset)
+static u8 bnx2x_e1h_cam_offset(struct bnx2x *bp, u8 rel_offset)
 {
        if (CHIP_IS_E1H(bp))
                return E1H_FUNC_MAX * rel_offset + BP_FUNC(bp);
@@ -6273,7 +6279,7 @@ static void bnx2x_invlidate_e1_mc_list(struct bnx2x *bp)
  *
  * @return 0 if cussess, -ENODEV if ramrod doesn't return.
  */
-int bnx2x_set_iscsi_eth_mac_addr(struct bnx2x *bp, int set)
+static int bnx2x_set_iscsi_eth_mac_addr(struct bnx2x *bp, int set)
 {
        u8 cam_offset = (CHIP_IS_E1(bp) ? ((BP_PORT(bp) ? 32 : 0) + 2) :
                         bnx2x_e1h_cam_offset(bp, CAM_ISCSI_ETH_LINE));
@@ -6383,11 +6389,11 @@ static inline void bnx2x_set_ctx_validation(struct eth_context *cxt, u32 cid)
                                       ETH_CONNECTION_TYPE);
 }
 
-int bnx2x_setup_fw_client(struct bnx2x *bp,
-                         struct bnx2x_client_init_params *params,
-                         u8 activate,
-                         struct client_init_ramrod_data *data,
-                         dma_addr_t data_mapping)
+static int bnx2x_setup_fw_client(struct bnx2x *bp,
+                                struct bnx2x_client_init_params *params,
+                                u8 activate,
+                                struct client_init_ramrod_data *data,
+                                dma_addr_t data_mapping)
 {
        u16 hc_usec;
        int ramrod = RAMROD_CMD_ID_ETH_CLIENT_SETUP;
@@ -6633,7 +6639,8 @@ int bnx2x_setup_client(struct bnx2x *bp, struct bnx2x_fastpath *fp,
        return rc;
 }
 
-int bnx2x_stop_fw_client(struct bnx2x *bp, struct bnx2x_client_ramrod_params *p)
+static int bnx2x_stop_fw_client(struct bnx2x *bp,
+                               struct bnx2x_client_ramrod_params *p)
 {
        int rc;
 
@@ -7440,7 +7447,7 @@ reset_task_exit:
  * Init service functions
  */
 
-u32 bnx2x_get_pretend_reg(struct bnx2x *bp)
+static u32 bnx2x_get_pretend_reg(struct bnx2x *bp)
 {
        u32 base = PXP2_REG_PGL_PRETEND_FUNC_F0;
        u32 stride = PXP2_REG_PGL_PRETEND_FUNC_F1 - base;
index 9d9e45394433f134ef8a344e69fe1d42039e7fcc..080574b0fff0c222510df389641c669d5fad1429 100644 (file)
@@ -82,6 +82,14 @@ config CAN_FLEXCAN
        ---help---
          Say Y here if you want to support for Freescale FlexCAN.
 
+config PCH_CAN
+       tristate "PCH CAN"
+       depends on CAN_DEV && PCI
+       ---help---
+         This driver is for PCH CAN of Topcliff which is an IOH for x86
+         embedded processor.
+         This driver can access CAN bus.
+
 source "drivers/net/can/mscan/Kconfig"
 
 source "drivers/net/can/sja1000/Kconfig"
index 00575373bbd0eed976566419be2ed9c9e34c8cf2..90af15a4f106a7031a8eafce16b6f2b9d3cc0eaf 100644 (file)
@@ -17,5 +17,6 @@ obj-$(CONFIG_CAN_MCP251X)     += mcp251x.o
 obj-$(CONFIG_CAN_BFIN)         += bfin_can.o
 obj-$(CONFIG_CAN_JANZ_ICAN3)   += janz-ican3.o
 obj-$(CONFIG_CAN_FLEXCAN)      += flexcan.o
+obj-$(CONFIG_PCH_CAN)          += pch_can.o
 
 ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
index 2d8bd86bc5e2072bf66d4966d5042869044fb0b9..cee98fa668bd703c9e34356acb9e6350c0ad80f5 100644 (file)
@@ -2,7 +2,7 @@
  * at91_can.c - CAN network driver for AT91 SoC CAN controller
  *
  * (C) 2007 by Hans J. Koch <hjk@linutronix.de>
- * (C) 2008, 2009 by Marc Kleine-Budde <kernel@pengutronix.de>
+ * (C) 2008, 2009, 2010 by Marc Kleine-Budde <kernel@pengutronix.de>
  *
  * This software may be distributed under the terms of the GNU General
  * Public License ("GPL") version 2 as distributed in the 'COPYING'
@@ -40,7 +40,6 @@
 
 #include <mach/board.h>
 
-#define DRV_NAME               "at91_can"
 #define AT91_NAPI_WEIGHT       12
 
 /*
@@ -172,6 +171,7 @@ struct at91_priv {
 };
 
 static struct can_bittiming_const at91_bittiming_const = {
+       .name           = KBUILD_MODNAME,
        .tseg1_min      = 4,
        .tseg1_max      = 16,
        .tseg2_min      = 2,
@@ -199,13 +199,13 @@ static inline int get_tx_echo_mb(const struct at91_priv *priv)
 
 static inline u32 at91_read(const struct at91_priv *priv, enum at91_reg reg)
 {
-       return readl(priv->reg_base + reg);
+       return __raw_readl(priv->reg_base + reg);
 }
 
 static inline void at91_write(const struct at91_priv *priv, enum at91_reg reg,
                u32 value)
 {
-       writel(value, priv->reg_base + reg);
+       __raw_writel(value, priv->reg_base + reg);
 }
 
 static inline void set_mb_mode_prio(const struct at91_priv *priv,
@@ -243,6 +243,12 @@ static void at91_setup_mailboxes(struct net_device *dev)
                set_mb_mode(priv, i, AT91_MB_MODE_RX);
        set_mb_mode(priv, AT91_MB_RX_LAST, AT91_MB_MODE_RX_OVRWR);
 
+       /* reset acceptance mask and id register */
+       for (i = AT91_MB_RX_FIRST; i <= AT91_MB_RX_LAST; i++) {
+               at91_write(priv, AT91_MAM(i), 0x0 );
+               at91_write(priv, AT91_MID(i), AT91_MID_MIDE);
+       }
+
        /* The last 4 mailboxes are used for transmitting. */
        for (i = AT91_MB_TX_FIRST; i <= AT91_MB_TX_LAST; i++)
                set_mb_mode_prio(priv, i, AT91_MB_MODE_TX, 0);
@@ -257,18 +263,30 @@ static int at91_set_bittiming(struct net_device *dev)
        const struct can_bittiming *bt = &priv->can.bittiming;
        u32 reg_br;
 
-       reg_br = ((priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) << 24) |
-               ((bt->brp - 1) << 16) | ((bt->sjw - 1) << 12) |
+       reg_br = ((priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) ? 1 << 24 : 0) |
+               ((bt->brp - 1) << 16) | ((bt->sjw - 1) << 12) |
                ((bt->prop_seg - 1) << 8) | ((bt->phase_seg1 - 1) << 4) |
                ((bt->phase_seg2 - 1) << 0);
 
-       dev_info(dev->dev.parent, "writing AT91_BR: 0x%08x\n", reg_br);
+       netdev_info(dev, "writing AT91_BR: 0x%08x\n", reg_br);
 
        at91_write(priv, AT91_BR, reg_br);
 
        return 0;
 }
 
+static int at91_get_berr_counter(const struct net_device *dev,
+               struct can_berr_counter *bec)
+{
+       const struct at91_priv *priv = netdev_priv(dev);
+       u32 reg_ecr = at91_read(priv, AT91_ECR);
+
+       bec->rxerr = reg_ecr & 0xff;
+       bec->txerr = reg_ecr >> 16;
+
+       return 0;
+}
+
 static void at91_chip_start(struct net_device *dev)
 {
        struct at91_priv *priv = netdev_priv(dev);
@@ -281,6 +299,7 @@ static void at91_chip_start(struct net_device *dev)
        reg_mr = at91_read(priv, AT91_MR);
        at91_write(priv, AT91_MR, reg_mr & ~AT91_MR_CANEN);
 
+       at91_set_bittiming(dev);
        at91_setup_mailboxes(dev);
        at91_transceiver_switch(priv, 1);
 
@@ -350,8 +369,7 @@ static netdev_tx_t at91_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (unlikely(!(at91_read(priv, AT91_MSR(mb)) & AT91_MSR_MRDY))) {
                netif_stop_queue(dev);
 
-               dev_err(dev->dev.parent,
-                       "BUG! TX buffer full when queue awake!\n");
+               netdev_err(dev, "BUG! TX buffer full when queue awake!\n");
                return NETDEV_TX_BUSY;
        }
 
@@ -435,7 +453,7 @@ static void at91_rx_overflow_err(struct net_device *dev)
        struct sk_buff *skb;
        struct can_frame *cf;
 
-       dev_dbg(dev->dev.parent, "RX buffer overflow\n");
+       netdev_dbg(dev, "RX buffer overflow\n");
        stats->rx_over_errors++;
        stats->rx_errors++;
 
@@ -480,6 +498,9 @@ static void at91_read_mb(struct net_device *dev, unsigned int mb,
        *(u32 *)(cf->data + 0) = at91_read(priv, AT91_MDL(mb));
        *(u32 *)(cf->data + 4) = at91_read(priv, AT91_MDH(mb));
 
+       /* allow RX of extended frames */
+       at91_write(priv, AT91_MID(mb), AT91_MID_MIDE);
+
        if (unlikely(mb == AT91_MB_RX_LAST && reg_msr & AT91_MSR_MMI))
                at91_rx_overflow_err(dev);
 }
@@ -565,8 +586,8 @@ static int at91_poll_rx(struct net_device *dev, int quota)
 
        if (priv->rx_next > AT91_MB_RX_LOW_LAST &&
            reg_sr & AT91_MB_RX_LOW_MASK)
-               dev_info(dev->dev.parent,
-                        "order of incoming frames cannot be guaranteed\n");
+               netdev_info(dev,
+                       "order of incoming frames cannot be guaranteed\n");
 
  again:
        for (mb = find_next_bit(addr, AT91_MB_RX_NUM, priv->rx_next);
@@ -604,7 +625,7 @@ static void at91_poll_err_frame(struct net_device *dev,
 
        /* CRC error */
        if (reg_sr & AT91_IRQ_CERR) {
-               dev_dbg(dev->dev.parent, "CERR irq\n");
+               netdev_dbg(dev, "CERR irq\n");
                dev->stats.rx_errors++;
                priv->can.can_stats.bus_error++;
                cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
@@ -612,7 +633,7 @@ static void at91_poll_err_frame(struct net_device *dev,
 
        /* Stuffing Error */
        if (reg_sr & AT91_IRQ_SERR) {
-               dev_dbg(dev->dev.parent, "SERR irq\n");
+               netdev_dbg(dev, "SERR irq\n");
                dev->stats.rx_errors++;
                priv->can.can_stats.bus_error++;
                cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
@@ -621,14 +642,14 @@ static void at91_poll_err_frame(struct net_device *dev,
 
        /* Acknowledgement Error */
        if (reg_sr & AT91_IRQ_AERR) {
-               dev_dbg(dev->dev.parent, "AERR irq\n");
+               netdev_dbg(dev, "AERR irq\n");
                dev->stats.tx_errors++;
                cf->can_id |= CAN_ERR_ACK;
        }
 
        /* Form error */
        if (reg_sr & AT91_IRQ_FERR) {
-               dev_dbg(dev->dev.parent, "FERR irq\n");
+               netdev_dbg(dev, "FERR irq\n");
                dev->stats.rx_errors++;
                priv->can.can_stats.bus_error++;
                cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
@@ -637,7 +658,7 @@ static void at91_poll_err_frame(struct net_device *dev,
 
        /* Bit Error */
        if (reg_sr & AT91_IRQ_BERR) {
-               dev_dbg(dev->dev.parent, "BERR irq\n");
+               netdev_dbg(dev, "BERR irq\n");
                dev->stats.tx_errors++;
                priv->can.can_stats.bus_error++;
                cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
@@ -755,12 +776,10 @@ static void at91_irq_err_state(struct net_device *dev,
                struct can_frame *cf, enum can_state new_state)
 {
        struct at91_priv *priv = netdev_priv(dev);
-       u32 reg_idr, reg_ier, reg_ecr;
-       u8 tec, rec;
+       u32 reg_idr = 0, reg_ier = 0;
+       struct can_berr_counter bec;
 
-       reg_ecr = at91_read(priv, AT91_ECR);
-       rec = reg_ecr & 0xff;
-       tec = reg_ecr >> 16;
+       at91_get_berr_counter(dev, &bec);
 
        switch (priv->can.state) {
        case CAN_STATE_ERROR_ACTIVE:
@@ -771,11 +790,11 @@ static void at91_irq_err_state(struct net_device *dev,
                 */
                if (new_state >= CAN_STATE_ERROR_WARNING &&
                    new_state <= CAN_STATE_BUS_OFF) {
-                       dev_dbg(dev->dev.parent, "Error Warning IRQ\n");
+                       netdev_dbg(dev, "Error Warning IRQ\n");
                        priv->can.can_stats.error_warning++;
 
                        cf->can_id |= CAN_ERR_CRTL;
-                       cf->data[1] = (tec > rec) ?
+                       cf->data[1] = (bec.txerr > bec.rxerr) ?
                                CAN_ERR_CRTL_TX_WARNING :
                                CAN_ERR_CRTL_RX_WARNING;
                }
@@ -787,11 +806,11 @@ static void at91_irq_err_state(struct net_device *dev,
                 */
                if (new_state >= CAN_STATE_ERROR_PASSIVE &&
                    new_state <= CAN_STATE_BUS_OFF) {
-                       dev_dbg(dev->dev.parent, "Error Passive IRQ\n");
+                       netdev_dbg(dev, "Error Passive IRQ\n");
                        priv->can.can_stats.error_passive++;
 
                        cf->can_id |= CAN_ERR_CRTL;
-                       cf->data[1] = (tec > rec) ?
+                       cf->data[1] = (bec.txerr > bec.rxerr) ?
                                CAN_ERR_CRTL_TX_PASSIVE :
                                CAN_ERR_CRTL_RX_PASSIVE;
                }
@@ -804,7 +823,7 @@ static void at91_irq_err_state(struct net_device *dev,
                if (new_state <= CAN_STATE_ERROR_PASSIVE) {
                        cf->can_id |= CAN_ERR_RESTARTED;
 
-                       dev_dbg(dev->dev.parent, "restarted\n");
+                       netdev_dbg(dev, "restarted\n");
                        priv->can.can_stats.restarts++;
 
                        netif_carrier_on(dev);
@@ -825,7 +844,7 @@ static void at91_irq_err_state(struct net_device *dev,
                 * circumstances. so just enable AT91_IRQ_ERRP, thus
                 * the "fallthrough"
                 */
-               dev_dbg(dev->dev.parent, "Error Active\n");
+               netdev_dbg(dev, "Error Active\n");
                cf->can_id |= CAN_ERR_PROT;
                cf->data[2] = CAN_ERR_PROT_ACTIVE;
        case CAN_STATE_ERROR_WARNING:   /* fallthrough */
@@ -843,7 +862,7 @@ static void at91_irq_err_state(struct net_device *dev,
 
                cf->can_id |= CAN_ERR_BUSOFF;
 
-               dev_dbg(dev->dev.parent, "bus-off\n");
+               netdev_dbg(dev, "bus-off\n");
                netif_carrier_off(dev);
                priv->can.can_stats.bus_off++;
 
@@ -881,7 +900,7 @@ static void at91_irq_err(struct net_device *dev)
        else if (likely(reg_sr & AT91_IRQ_ERRA))
                new_state = CAN_STATE_ERROR_ACTIVE;
        else {
-               dev_err(dev->dev.parent, "BUG! hardware in undefined state\n");
+               netdev_err(dev, "BUG! hardware in undefined state\n");
                return;
        }
 
@@ -1018,7 +1037,7 @@ static const struct net_device_ops at91_netdev_ops = {
        .ndo_start_xmit = at91_start_xmit,
 };
 
-static int __init at91_can_probe(struct platform_device *pdev)
+static int __devinit at91_can_probe(struct platform_device *pdev)
 {
        struct net_device *dev;
        struct at91_priv *priv;
@@ -1067,8 +1086,8 @@ static int __init at91_can_probe(struct platform_device *pdev)
        priv = netdev_priv(dev);
        priv->can.clock.freq = clk_get_rate(clk);
        priv->can.bittiming_const = &at91_bittiming_const;
-       priv->can.do_set_bittiming = at91_set_bittiming;
        priv->can.do_set_mode = at91_set_mode;
+       priv->can.do_get_berr_counter = at91_get_berr_counter;
        priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
        priv->reg_base = addr;
        priv->dev = dev;
@@ -1092,7 +1111,7 @@ static int __init at91_can_probe(struct platform_device *pdev)
        return 0;
 
  exit_free:
-       free_netdev(dev);
+       free_candev(dev);
  exit_iounmap:
        iounmap(addr);
  exit_release:
@@ -1113,8 +1132,6 @@ static int __devexit at91_can_remove(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, NULL);
 
-       free_netdev(dev);
-
        iounmap(priv->reg_base);
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1122,6 +1139,8 @@ static int __devexit at91_can_remove(struct platform_device *pdev)
 
        clk_put(priv->clk);
 
+       free_candev(dev);
+
        return 0;
 }
 
@@ -1129,21 +1148,19 @@ static struct platform_driver at91_can_driver = {
        .probe          = at91_can_probe,
        .remove         = __devexit_p(at91_can_remove),
        .driver         = {
-               .name   = DRV_NAME,
+               .name   = KBUILD_MODNAME,
                .owner  = THIS_MODULE,
        },
 };
 
 static int __init at91_can_module_init(void)
 {
-       printk(KERN_INFO "%s netdevice driver\n", DRV_NAME);
        return platform_driver_register(&at91_can_driver);
 }
 
 static void __exit at91_can_module_exit(void)
 {
        platform_driver_unregister(&at91_can_driver);
-       printk(KERN_INFO "%s: driver removed\n", DRV_NAME);
 }
 
 module_init(at91_can_module_init);
@@ -1151,4 +1168,4 @@ module_exit(at91_can_module_exit);
 
 MODULE_AUTHOR("Marc Kleine-Budde <mkl@pengutronix.de>");
 MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION(DRV_NAME " CAN netdevice driver");
+MODULE_DESCRIPTION(KBUILD_MODNAME " CAN netdevice driver");
index ef443a090ba7cc53a8db4989095bfd888712890c..d4990568baee071cd5ceaaac9a91c6bc5d6cf7c9 100644 (file)
@@ -992,7 +992,6 @@ static int __devexit flexcan_remove(struct platform_device *pdev)
 
        unregister_flexcandev(dev);
        platform_set_drvdata(pdev, NULL);
-       free_candev(dev);
        iounmap(priv->base);
 
        mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1000,6 +999,8 @@ static int __devexit flexcan_remove(struct platform_device *pdev)
 
        clk_put(priv->clk);
 
+       free_candev(dev);
+
        return 0;
 }
 
index 6aadc3e32bd5c8bc31c1d5c231e1e9ff99ae9188..7ab534aee4525ded6c8db75e0dde6cbd542d618d 100644 (file)
 #  define RXBSIDH_SHIFT 3
 #define RXBSIDL(n)  (((n) * 0x10) + 0x60 + RXBSIDL_OFF)
 #  define RXBSIDL_IDE   0x08
+#  define RXBSIDL_SRR   0x10
 #  define RXBSIDL_EID   3
 #  define RXBSIDL_SHIFT 5
 #define RXBEID8(n)  (((n) * 0x10) + 0x60 + RXBEID8_OFF)
@@ -475,6 +476,8 @@ static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx)
                frame->can_id =
                        (buf[RXBSIDH_OFF] << RXBSIDH_SHIFT) |
                        (buf[RXBSIDL_OFF] >> RXBSIDL_SHIFT);
+               if (buf[RXBSIDL_OFF] & RXBSIDL_SRR)
+                       frame->can_id |= CAN_RTR_FLAG;
        }
        /* Data length */
        frame->can_dlc = get_can_dlc(buf[RXBDLC_OFF] & RXBDLC_LEN_MASK);
diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
new file mode 100644 (file)
index 0000000..55ec324
--- /dev/null
@@ -0,0 +1,1463 @@
+/*
+ * Copyright (C) 1999 - 2010 Intel Corporation.
+ * Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+#include <linux/can.h>
+#include <linux/can/dev.h>
+#include <linux/can/error.h>
+
+#define MAX_MSG_OBJ            32
+#define MSG_OBJ_RX             0 /* The receive message object flag. */
+#define MSG_OBJ_TX             1 /* The transmit message object flag. */
+
+#define ENABLE                 1 /* The enable flag */
+#define DISABLE                        0 /* The disable flag */
+#define CAN_CTRL_INIT          0x0001 /* The INIT bit of CANCONT register. */
+#define CAN_CTRL_IE            0x0002 /* The IE bit of CAN control register */
+#define CAN_CTRL_IE_SIE_EIE    0x000e
+#define CAN_CTRL_CCE           0x0040
+#define CAN_CTRL_OPT           0x0080 /* The OPT bit of CANCONT register. */
+#define CAN_OPT_SILENT         0x0008 /* The Silent bit of CANOPT reg. */
+#define CAN_OPT_LBACK          0x0010 /* The LoopBack bit of CANOPT reg. */
+#define CAN_CMASK_RX_TX_SET    0x00f3
+#define CAN_CMASK_RX_TX_GET    0x0073
+#define CAN_CMASK_ALL          0xff
+#define CAN_CMASK_RDWR         0x80
+#define CAN_CMASK_ARB          0x20
+#define CAN_CMASK_CTRL         0x10
+#define CAN_CMASK_MASK         0x40
+#define CAN_CMASK_NEWDAT       0x04
+#define CAN_CMASK_CLRINTPND    0x08
+
+#define CAN_IF_MCONT_NEWDAT    0x8000
+#define CAN_IF_MCONT_INTPND    0x2000
+#define CAN_IF_MCONT_UMASK     0x1000
+#define CAN_IF_MCONT_TXIE      0x0800
+#define CAN_IF_MCONT_RXIE      0x0400
+#define CAN_IF_MCONT_RMTEN     0x0200
+#define CAN_IF_MCONT_TXRQXT    0x0100
+#define CAN_IF_MCONT_EOB       0x0080
+#define CAN_IF_MCONT_DLC       0x000f
+#define CAN_IF_MCONT_MSGLOST   0x4000
+#define CAN_MASK2_MDIR_MXTD    0xc000
+#define CAN_ID2_DIR            0x2000
+#define CAN_ID_MSGVAL          0x8000
+
+#define CAN_STATUS_INT         0x8000
+#define CAN_IF_CREQ_BUSY       0x8000
+#define CAN_ID2_XTD            0x4000
+
+#define CAN_REC                        0x00007f00
+#define CAN_TEC                        0x000000ff
+
+#define PCH_RX_OK              0x00000010
+#define PCH_TX_OK              0x00000008
+#define PCH_BUS_OFF            0x00000080
+#define PCH_EWARN              0x00000040
+#define PCH_EPASSIV            0x00000020
+#define PCH_LEC0               0x00000001
+#define PCH_LEC1               0x00000002
+#define PCH_LEC2               0x00000004
+#define PCH_LEC_ALL            (PCH_LEC0 | PCH_LEC1 | PCH_LEC2)
+#define PCH_STUF_ERR           PCH_LEC0
+#define PCH_FORM_ERR           PCH_LEC1
+#define PCH_ACK_ERR            (PCH_LEC0 | PCH_LEC1)
+#define PCH_BIT1_ERR           PCH_LEC2
+#define PCH_BIT0_ERR           (PCH_LEC0 | PCH_LEC2)
+#define PCH_CRC_ERR            (PCH_LEC1 | PCH_LEC2)
+
+/* bit position of certain controller bits. */
+#define BIT_BITT_BRP           0
+#define BIT_BITT_SJW           6
+#define BIT_BITT_TSEG1         8
+#define BIT_BITT_TSEG2         12
+#define BIT_IF1_MCONT_RXIE     10
+#define BIT_IF2_MCONT_TXIE     11
+#define BIT_BRPE_BRPE          6
+#define BIT_ES_TXERRCNT                0
+#define BIT_ES_RXERRCNT                8
+#define MSK_BITT_BRP           0x3f
+#define MSK_BITT_SJW           0xc0
+#define MSK_BITT_TSEG1         0xf00
+#define MSK_BITT_TSEG2         0x7000
+#define MSK_BRPE_BRPE          0x3c0
+#define MSK_BRPE_GET           0x0f
+#define MSK_CTRL_IE_SIE_EIE    0x07
+#define MSK_MCONT_TXIE         0x08
+#define MSK_MCONT_RXIE         0x10
+#define PCH_CAN_NO_TX_BUFF     1
+#define COUNTER_LIMIT          10
+
+#define PCH_CAN_CLK            50000000        /* 50MHz */
+
+/* Define the number of message object.
+ * PCH CAN communications are done via Message RAM.
+ * The Message RAM consists of 32 message objects. */
+#define PCH_RX_OBJ_NUM         26  /* 1~ PCH_RX_OBJ_NUM is Rx*/
+#define PCH_TX_OBJ_NUM         6  /* PCH_RX_OBJ_NUM is RX ~ Tx*/
+#define PCH_OBJ_NUM            (PCH_TX_OBJ_NUM + PCH_RX_OBJ_NUM)
+
+#define PCH_FIFO_THRESH                16
+
+enum pch_can_mode {
+       PCH_CAN_ENABLE,
+       PCH_CAN_DISABLE,
+       PCH_CAN_ALL,
+       PCH_CAN_NONE,
+       PCH_CAN_STOP,
+       PCH_CAN_RUN
+};
+
+struct pch_can_regs {
+       u32 cont;
+       u32 stat;
+       u32 errc;
+       u32 bitt;
+       u32 intr;
+       u32 opt;
+       u32 brpe;
+       u32 reserve1;
+       u32 if1_creq;
+       u32 if1_cmask;
+       u32 if1_mask1;
+       u32 if1_mask2;
+       u32 if1_id1;
+       u32 if1_id2;
+       u32 if1_mcont;
+       u32 if1_dataa1;
+       u32 if1_dataa2;
+       u32 if1_datab1;
+       u32 if1_datab2;
+       u32 reserve2;
+       u32 reserve3[12];
+       u32 if2_creq;
+       u32 if2_cmask;
+       u32 if2_mask1;
+       u32 if2_mask2;
+       u32 if2_id1;
+       u32 if2_id2;
+       u32 if2_mcont;
+       u32 if2_dataa1;
+       u32 if2_dataa2;
+       u32 if2_datab1;
+       u32 if2_datab2;
+       u32 reserve4;
+       u32 reserve5[20];
+       u32 treq1;
+       u32 treq2;
+       u32 reserve6[2];
+       u32 reserve7[56];
+       u32 reserve8[3];
+       u32 srst;
+};
+
+struct pch_can_priv {
+       struct can_priv can;
+       unsigned int can_num;
+       struct pci_dev *dev;
+       unsigned int tx_enable[MAX_MSG_OBJ];
+       unsigned int rx_enable[MAX_MSG_OBJ];
+       unsigned int rx_link[MAX_MSG_OBJ];
+       unsigned int int_enables;
+       unsigned int int_stat;
+       struct net_device *ndev;
+       spinlock_t msgif_reg_lock; /* Message Interface Registers Access Lock*/
+       unsigned int msg_obj[MAX_MSG_OBJ];
+       struct pch_can_regs __iomem *regs;
+       struct napi_struct napi;
+       unsigned int tx_obj;    /* Point next Tx Obj index */
+       unsigned int use_msi;
+};
+
+static struct can_bittiming_const pch_can_bittiming_const = {
+       .name = KBUILD_MODNAME,
+       .tseg1_min = 1,
+       .tseg1_max = 16,
+       .tseg2_min = 1,
+       .tseg2_max = 8,
+       .sjw_max = 4,
+       .brp_min = 1,
+       .brp_max = 1024, /* 6bit + extended 4bit */
+       .brp_inc = 1,
+};
+
+static DEFINE_PCI_DEVICE_TABLE(pch_pci_tbl) = {
+       {PCI_VENDOR_ID_INTEL, 0x8818, PCI_ANY_ID, PCI_ANY_ID,},
+       {0,}
+};
+MODULE_DEVICE_TABLE(pci, pch_pci_tbl);
+
+static inline void pch_can_bit_set(u32 *addr, u32 mask)
+{
+       iowrite32(ioread32(addr) | mask, addr);
+}
+
+static inline void pch_can_bit_clear(u32 *addr, u32 mask)
+{
+       iowrite32(ioread32(addr) & ~mask, addr);
+}
+
+static void pch_can_set_run_mode(struct pch_can_priv *priv,
+                                enum pch_can_mode mode)
+{
+       switch (mode) {
+       case PCH_CAN_RUN:
+               pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_INIT);
+               break;
+
+       case PCH_CAN_STOP:
+               pch_can_bit_set(&priv->regs->cont, CAN_CTRL_INIT);
+               break;
+
+       default:
+               dev_err(&priv->ndev->dev, "%s -> Invalid Mode.\n", __func__);
+               break;
+       }
+}
+
+static void pch_can_set_optmode(struct pch_can_priv *priv)
+{
+       u32 reg_val = ioread32(&priv->regs->opt);
+
+       if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
+               reg_val |= CAN_OPT_SILENT;
+
+       if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
+               reg_val |= CAN_OPT_LBACK;
+
+       pch_can_bit_set(&priv->regs->cont, CAN_CTRL_OPT);
+       iowrite32(reg_val, &priv->regs->opt);
+}
+
+static void pch_can_set_int_custom(struct pch_can_priv *priv)
+{
+       /* Clearing the IE, SIE and EIE bits of Can control register. */
+       pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_IE_SIE_EIE);
+
+       /* Appropriately setting them. */
+       pch_can_bit_set(&priv->regs->cont,
+                       ((priv->int_enables & MSK_CTRL_IE_SIE_EIE) << 1));
+}
+
+/* This function retrieves interrupt enabled for the CAN device. */
+static void pch_can_get_int_enables(struct pch_can_priv *priv, u32 *enables)
+{
+       /* Obtaining the status of IE, SIE and EIE interrupt bits. */
+       *enables = ((ioread32(&priv->regs->cont) & CAN_CTRL_IE_SIE_EIE) >> 1);
+}
+
+static void pch_can_set_int_enables(struct pch_can_priv *priv,
+                                   enum pch_can_mode interrupt_no)
+{
+       switch (interrupt_no) {
+       case PCH_CAN_ENABLE:
+               pch_can_bit_set(&priv->regs->cont, CAN_CTRL_IE);
+               break;
+
+       case PCH_CAN_DISABLE:
+               pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_IE);
+               break;
+
+       case PCH_CAN_ALL:
+               pch_can_bit_set(&priv->regs->cont, CAN_CTRL_IE_SIE_EIE);
+               break;
+
+       case PCH_CAN_NONE:
+               pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_IE_SIE_EIE);
+               break;
+
+       default:
+               dev_err(&priv->ndev->dev, "Invalid interrupt number.\n");
+               break;
+       }
+}
+
+static void pch_can_check_if_busy(u32 __iomem *creq_addr, u32 num)
+{
+       u32 counter = COUNTER_LIMIT;
+       u32 ifx_creq;
+
+       iowrite32(num, creq_addr);
+       while (counter) {
+               ifx_creq = ioread32(creq_addr) & CAN_IF_CREQ_BUSY;
+               if (!ifx_creq)
+                       break;
+               counter--;
+               udelay(1);
+       }
+       if (!counter)
+               pr_err("%s:IF1 BUSY Flag is set forever.\n", __func__);
+}
+
+static void pch_can_set_rx_enable(struct pch_can_priv *priv, u32 buff_num,
+                                 u32 set)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+       /* Reading the receive buffer data from RAM to Interface1 registers */
+       iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
+       pch_can_check_if_busy(&priv->regs->if1_creq, buff_num);
+
+       /* Setting the IF1MASK1 register to access MsgVal and RxIE bits */
+       iowrite32(CAN_CMASK_RDWR | CAN_CMASK_ARB | CAN_CMASK_CTRL,
+                 &priv->regs->if1_cmask);
+
+       if (set == ENABLE) {
+               /* Setting the MsgVal and RxIE bits */
+               pch_can_bit_set(&priv->regs->if1_mcont, CAN_IF_MCONT_RXIE);
+               pch_can_bit_set(&priv->regs->if1_id2, CAN_ID_MSGVAL);
+
+       } else if (set == DISABLE) {
+               /* Resetting the MsgVal and RxIE bits */
+               pch_can_bit_clear(&priv->regs->if1_mcont, CAN_IF_MCONT_RXIE);
+               pch_can_bit_clear(&priv->regs->if1_id2, CAN_ID_MSGVAL);
+       }
+
+       pch_can_check_if_busy(&priv->regs->if1_creq, buff_num);
+       spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
+static void pch_can_rx_enable_all(struct pch_can_priv *priv)
+{
+       int i;
+
+       /* Traversing to obtain the object configured as receivers. */
+       for (i = 0; i < PCH_OBJ_NUM; i++) {
+               if (priv->msg_obj[i] == MSG_OBJ_RX)
+                       pch_can_set_rx_enable(priv, i + 1, ENABLE);
+       }
+}
+
+static void pch_can_rx_disable_all(struct pch_can_priv *priv)
+{
+       int i;
+
+       /* Traversing to obtain the object configured as receivers. */
+       for (i = 0; i < PCH_OBJ_NUM; i++) {
+               if (priv->msg_obj[i] == MSG_OBJ_RX)
+                       pch_can_set_rx_enable(priv, i + 1, DISABLE);
+       }
+}
+
+static void pch_can_set_tx_enable(struct pch_can_priv *priv, u32 buff_num,
+                                u32 set)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+       /* Reading the Msg buffer from Message RAM to Interface2 registers. */
+       iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
+       pch_can_check_if_busy(&priv->regs->if2_creq, buff_num);
+
+       /* Setting the IF2CMASK register for accessing the
+               MsgVal and TxIE bits */
+       iowrite32(CAN_CMASK_RDWR | CAN_CMASK_ARB | CAN_CMASK_CTRL,
+                &priv->regs->if2_cmask);
+
+       if (set == ENABLE) {
+               /* Setting the MsgVal and TxIE bits */
+               pch_can_bit_set(&priv->regs->if2_mcont, CAN_IF_MCONT_TXIE);
+               pch_can_bit_set(&priv->regs->if2_id2, CAN_ID_MSGVAL);
+       } else if (set == DISABLE) {
+               /* Resetting the MsgVal and TxIE bits. */
+               pch_can_bit_clear(&priv->regs->if2_mcont, CAN_IF_MCONT_TXIE);
+               pch_can_bit_clear(&priv->regs->if2_id2, CAN_ID_MSGVAL);
+       }
+
+       pch_can_check_if_busy(&priv->regs->if2_creq, buff_num);
+       spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
+static void pch_can_tx_enable_all(struct pch_can_priv *priv)
+{
+       int i;
+
+       /* Traversing to obtain the object configured as transmit object. */
+       for (i = 0; i < PCH_OBJ_NUM; i++) {
+               if (priv->msg_obj[i] == MSG_OBJ_TX)
+                       pch_can_set_tx_enable(priv, i + 1, ENABLE);
+       }
+}
+
+static void pch_can_tx_disable_all(struct pch_can_priv *priv)
+{
+       int i;
+
+       /* Traversing to obtain the object configured as transmit object. */
+       for (i = 0; i < PCH_OBJ_NUM; i++) {
+               if (priv->msg_obj[i] == MSG_OBJ_TX)
+                       pch_can_set_tx_enable(priv, i + 1, DISABLE);
+       }
+}
+
+static void pch_can_get_rx_enable(struct pch_can_priv *priv, u32 buff_num,
+                                u32 *enable)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+       iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
+       pch_can_check_if_busy(&priv->regs->if1_creq, buff_num);
+
+       if (((ioread32(&priv->regs->if1_id2)) & CAN_ID_MSGVAL) &&
+                       ((ioread32(&priv->regs->if1_mcont)) &
+                       CAN_IF_MCONT_RXIE))
+               *enable = ENABLE;
+       else
+               *enable = DISABLE;
+       spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
+static void pch_can_get_tx_enable(struct pch_can_priv *priv, u32 buff_num,
+                                u32 *enable)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+       iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
+       pch_can_check_if_busy(&priv->regs->if2_creq, buff_num);
+
+       if (((ioread32(&priv->regs->if2_id2)) & CAN_ID_MSGVAL) &&
+                       ((ioread32(&priv->regs->if2_mcont)) &
+                       CAN_IF_MCONT_TXIE)) {
+               *enable = ENABLE;
+       } else {
+               *enable = DISABLE;
+       }
+       spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
+static int pch_can_int_pending(struct pch_can_priv *priv)
+{
+       return ioread32(&priv->regs->intr) & 0xffff;
+}
+
+static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv,
+                                      u32 buffer_num, u32 set)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+       iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
+       pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
+       iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL, &priv->regs->if1_cmask);
+       if (set == ENABLE)
+               pch_can_bit_clear(&priv->regs->if1_mcont, CAN_IF_MCONT_EOB);
+       else
+               pch_can_bit_set(&priv->regs->if1_mcont, CAN_IF_MCONT_EOB);
+
+       pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
+       spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
+static void pch_can_get_rx_buffer_link(struct pch_can_priv *priv,
+                                      u32 buffer_num, u32 *link)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+       iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
+       pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
+
+       if (ioread32(&priv->regs->if1_mcont) & CAN_IF_MCONT_EOB)
+               *link = DISABLE;
+       else
+               *link = ENABLE;
+       spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
+static void pch_can_clear_buffers(struct pch_can_priv *priv)
+{
+       int i;
+
+       for (i = 0; i < PCH_RX_OBJ_NUM; i++) {
+               iowrite32(CAN_CMASK_RX_TX_SET, &priv->regs->if1_cmask);
+               iowrite32(0xffff, &priv->regs->if1_mask1);
+               iowrite32(0xffff, &priv->regs->if1_mask2);
+               iowrite32(0x0, &priv->regs->if1_id1);
+               iowrite32(0x0, &priv->regs->if1_id2);
+               iowrite32(0x0, &priv->regs->if1_mcont);
+               iowrite32(0x0, &priv->regs->if1_dataa1);
+               iowrite32(0x0, &priv->regs->if1_dataa2);
+               iowrite32(0x0, &priv->regs->if1_datab1);
+               iowrite32(0x0, &priv->regs->if1_datab2);
+               iowrite32(CAN_CMASK_RDWR | CAN_CMASK_MASK |
+                         CAN_CMASK_ARB | CAN_CMASK_CTRL,
+                         &priv->regs->if1_cmask);
+               pch_can_check_if_busy(&priv->regs->if1_creq, i+1);
+       }
+
+       for (i = i;  i < PCH_OBJ_NUM; i++) {
+               iowrite32(CAN_CMASK_RX_TX_SET, &priv->regs->if2_cmask);
+               iowrite32(0xffff, &priv->regs->if2_mask1);
+               iowrite32(0xffff, &priv->regs->if2_mask2);
+               iowrite32(0x0, &priv->regs->if2_id1);
+               iowrite32(0x0, &priv->regs->if2_id2);
+               iowrite32(0x0, &priv->regs->if2_mcont);
+               iowrite32(0x0, &priv->regs->if2_dataa1);
+               iowrite32(0x0, &priv->regs->if2_dataa2);
+               iowrite32(0x0, &priv->regs->if2_datab1);
+               iowrite32(0x0, &priv->regs->if2_datab2);
+               iowrite32(CAN_CMASK_RDWR | CAN_CMASK_MASK |
+                         CAN_CMASK_ARB | CAN_CMASK_CTRL,
+                         &priv->regs->if2_cmask);
+               pch_can_check_if_busy(&priv->regs->if2_creq, i+1);
+       }
+}
+
+static void pch_can_config_rx_tx_buffers(struct pch_can_priv *priv)
+{
+       int i;
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+
+       for (i = 0; i < PCH_OBJ_NUM; i++) {
+               if (priv->msg_obj[i] == MSG_OBJ_RX) {
+                       iowrite32(CAN_CMASK_RX_TX_GET,
+                               &priv->regs->if1_cmask);
+                       pch_can_check_if_busy(&priv->regs->if1_creq, i+1);
+
+                       iowrite32(0x0, &priv->regs->if1_id1);
+                       iowrite32(0x0, &priv->regs->if1_id2);
+
+                       pch_can_bit_set(&priv->regs->if1_mcont,
+                                       CAN_IF_MCONT_UMASK);
+
+                       /* Set FIFO mode set to 0 except last Rx Obj*/
+                       pch_can_bit_clear(&priv->regs->if1_mcont,
+                                         CAN_IF_MCONT_EOB);
+                       /* In case FIFO mode, Last EoB of Rx Obj must be 1 */
+                       if (i == (PCH_RX_OBJ_NUM - 1))
+                               pch_can_bit_set(&priv->regs->if1_mcont,
+                                                 CAN_IF_MCONT_EOB);
+
+                       iowrite32(0, &priv->regs->if1_mask1);
+                       pch_can_bit_clear(&priv->regs->if1_mask2,
+                                         0x1fff | CAN_MASK2_MDIR_MXTD);
+
+                       /* Setting CMASK for writing */
+                       iowrite32(CAN_CMASK_RDWR | CAN_CMASK_MASK |
+                                 CAN_CMASK_ARB | CAN_CMASK_CTRL,
+                                 &priv->regs->if1_cmask);
+
+                       pch_can_check_if_busy(&priv->regs->if1_creq, i+1);
+               } else if (priv->msg_obj[i] == MSG_OBJ_TX) {
+                       iowrite32(CAN_CMASK_RX_TX_GET,
+                               &priv->regs->if2_cmask);
+                       pch_can_check_if_busy(&priv->regs->if2_creq, i+1);
+
+                       /* Resetting DIR bit for reception */
+                       iowrite32(0x0, &priv->regs->if2_id1);
+                       iowrite32(0x0, &priv->regs->if2_id2);
+                       pch_can_bit_set(&priv->regs->if2_id2, CAN_ID2_DIR);
+
+                       /* Setting EOB bit for transmitter */
+                       iowrite32(CAN_IF_MCONT_EOB, &priv->regs->if2_mcont);
+
+                       pch_can_bit_set(&priv->regs->if2_mcont,
+                                       CAN_IF_MCONT_UMASK);
+
+                       iowrite32(0, &priv->regs->if2_mask1);
+                       pch_can_bit_clear(&priv->regs->if2_mask2, 0x1fff);
+
+                       /* Setting CMASK for writing */
+                       iowrite32(CAN_CMASK_RDWR | CAN_CMASK_MASK |
+                                 CAN_CMASK_ARB | CAN_CMASK_CTRL,
+                                 &priv->regs->if2_cmask);
+
+                       pch_can_check_if_busy(&priv->regs->if2_creq, i+1);
+               }
+       }
+       spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+}
+
+static void pch_can_init(struct pch_can_priv *priv)
+{
+       /* Stopping the Can device. */
+       pch_can_set_run_mode(priv, PCH_CAN_STOP);
+
+       /* Clearing all the message object buffers. */
+       pch_can_clear_buffers(priv);
+
+       /* Configuring the respective message object as either rx/tx object. */
+       pch_can_config_rx_tx_buffers(priv);
+
+       /* Enabling the interrupts. */
+       pch_can_set_int_enables(priv, PCH_CAN_ALL);
+}
+
+static void pch_can_release(struct pch_can_priv *priv)
+{
+       /* Stooping the CAN device. */
+       pch_can_set_run_mode(priv, PCH_CAN_STOP);
+
+       /* Disabling the interrupts. */
+       pch_can_set_int_enables(priv, PCH_CAN_NONE);
+
+       /* Disabling all the receive object. */
+       pch_can_rx_disable_all(priv);
+
+       /* Disabling all the transmit object. */
+       pch_can_tx_disable_all(priv);
+}
+
+/* This function clears interrupt(s) from the CAN device. */
+static void pch_can_int_clr(struct pch_can_priv *priv, u32 mask)
+{
+       if (mask == CAN_STATUS_INT) {
+               ioread32(&priv->regs->stat);
+               return;
+       }
+
+       /* Clear interrupt for transmit object */
+       if (priv->msg_obj[mask - 1] == MSG_OBJ_TX) {
+               /* Setting CMASK for clearing interrupts for
+                                        frame transmission. */
+               iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL | CAN_CMASK_ARB,
+                         &priv->regs->if2_cmask);
+
+               /* Resetting the ID registers. */
+               pch_can_bit_set(&priv->regs->if2_id2,
+                              CAN_ID2_DIR | (0x7ff << 2));
+               iowrite32(0x0, &priv->regs->if2_id1);
+
+               /* Claring NewDat, TxRqst & IntPnd */
+               pch_can_bit_clear(&priv->regs->if2_mcont,
+                                 CAN_IF_MCONT_NEWDAT | CAN_IF_MCONT_INTPND |
+                                 CAN_IF_MCONT_TXRQXT);
+               pch_can_check_if_busy(&priv->regs->if2_creq, mask);
+       } else if (priv->msg_obj[mask - 1] == MSG_OBJ_RX) {
+               /* Setting CMASK for clearing the reception interrupts. */
+               iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL | CAN_CMASK_ARB,
+                         &priv->regs->if1_cmask);
+
+               /* Clearing the Dir bit. */
+               pch_can_bit_clear(&priv->regs->if1_id2, CAN_ID2_DIR);
+
+               /* Clearing NewDat & IntPnd */
+               pch_can_bit_clear(&priv->regs->if1_mcont,
+                                 CAN_IF_MCONT_NEWDAT | CAN_IF_MCONT_INTPND);
+
+               pch_can_check_if_busy(&priv->regs->if1_creq, mask);
+       }
+}
+
+static int pch_can_get_buffer_status(struct pch_can_priv *priv)
+{
+       return (ioread32(&priv->regs->treq1) & 0xffff) |
+              ((ioread32(&priv->regs->treq2) & 0xffff) << 16);
+}
+
+static void pch_can_reset(struct pch_can_priv *priv)
+{
+       /* write to sw reset register */
+       iowrite32(1, &priv->regs->srst);
+       iowrite32(0, &priv->regs->srst);
+}
+
+static void pch_can_error(struct net_device *ndev, u32 status)
+{
+       struct sk_buff *skb;
+       struct pch_can_priv *priv = netdev_priv(ndev);
+       struct can_frame *cf;
+       u32 errc;
+       struct net_device_stats *stats = &(priv->ndev->stats);
+       enum can_state state = priv->can.state;
+
+       skb = alloc_can_err_skb(ndev, &cf);
+       if (!skb)
+               return;
+
+       if (status & PCH_BUS_OFF) {
+               pch_can_tx_disable_all(priv);
+               pch_can_rx_disable_all(priv);
+               state = CAN_STATE_BUS_OFF;
+               cf->can_id |= CAN_ERR_BUSOFF;
+               can_bus_off(ndev);
+               pch_can_set_run_mode(priv, PCH_CAN_RUN);
+               dev_err(&ndev->dev, "%s -> Bus Off occurres.\n", __func__);
+       }
+
+       /* Warning interrupt. */
+       if (status & PCH_EWARN) {
+               state = CAN_STATE_ERROR_WARNING;
+               priv->can.can_stats.error_warning++;
+               cf->can_id |= CAN_ERR_CRTL;
+               errc = ioread32(&priv->regs->errc);
+               if (((errc & CAN_REC) >> 8) > 96)
+                       cf->data[1] |= CAN_ERR_CRTL_RX_WARNING;
+               if ((errc & CAN_TEC) > 96)
+                       cf->data[1] |= CAN_ERR_CRTL_TX_WARNING;
+               dev_warn(&ndev->dev,
+                       "%s -> Error Counter is more than 96.\n", __func__);
+       }
+       /* Error passive interrupt. */
+       if (status & PCH_EPASSIV) {
+               priv->can.can_stats.error_passive++;
+               state = CAN_STATE_ERROR_PASSIVE;
+               cf->can_id |= CAN_ERR_CRTL;
+               errc = ioread32(&priv->regs->errc);
+               if (((errc & CAN_REC) >> 8) > 127)
+                       cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE;
+               if ((errc & CAN_TEC) > 127)
+                       cf->data[1] |= CAN_ERR_CRTL_TX_PASSIVE;
+               dev_err(&ndev->dev,
+                       "%s -> CAN controller is ERROR PASSIVE .\n", __func__);
+       }
+
+       if (status & PCH_LEC_ALL) {
+               priv->can.can_stats.bus_error++;
+               stats->rx_errors++;
+               switch (status & PCH_LEC_ALL) {
+               case PCH_STUF_ERR:
+                       cf->data[2] |= CAN_ERR_PROT_STUFF;
+                       break;
+               case PCH_FORM_ERR:
+                       cf->data[2] |= CAN_ERR_PROT_FORM;
+                       break;
+               case PCH_ACK_ERR:
+                       cf->data[2] |= CAN_ERR_PROT_LOC_ACK |
+                                      CAN_ERR_PROT_LOC_ACK_DEL;
+                       break;
+               case PCH_BIT1_ERR:
+               case PCH_BIT0_ERR:
+                       cf->data[2] |= CAN_ERR_PROT_BIT;
+                       break;
+               case PCH_CRC_ERR:
+                       cf->data[2] |= CAN_ERR_PROT_LOC_CRC_SEQ |
+                                      CAN_ERR_PROT_LOC_CRC_DEL;
+                       break;
+               default:
+                       iowrite32(status | PCH_LEC_ALL, &priv->regs->stat);
+                       break;
+               }
+
+       }
+
+       priv->can.state = state;
+       netif_rx(skb);
+
+       stats->rx_packets++;
+       stats->rx_bytes += cf->can_dlc;
+}
+
+static irqreturn_t pch_can_interrupt(int irq, void *dev_id)
+{
+       struct net_device *ndev = (struct net_device *)dev_id;
+       struct pch_can_priv *priv = netdev_priv(ndev);
+
+       pch_can_set_int_enables(priv, PCH_CAN_NONE);
+
+       napi_schedule(&priv->napi);
+
+       return IRQ_HANDLED;
+}
+
+static int pch_can_rx_normal(struct net_device *ndev, u32 int_stat)
+{
+       u32 reg;
+       canid_t id;
+       u32 ide;
+       u32 rtr;
+       int i, j, k;
+       int rcv_pkts = 0;
+       struct sk_buff *skb;
+       struct can_frame *cf;
+       struct pch_can_priv *priv = netdev_priv(ndev);
+       struct net_device_stats *stats = &(priv->ndev->stats);
+
+       /* Reading the messsage object from the Message RAM */
+       iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
+       pch_can_check_if_busy(&priv->regs->if1_creq, int_stat);
+
+       /* Reading the MCONT register. */
+       reg = ioread32(&priv->regs->if1_mcont);
+       reg &= 0xffff;
+
+       for (k = int_stat; !(reg & CAN_IF_MCONT_EOB); k++) {
+               /* If MsgLost bit set. */
+               if (reg & CAN_IF_MCONT_MSGLOST) {
+                       dev_err(&priv->ndev->dev, "Msg Obj is overwritten.\n");
+                       pch_can_bit_clear(&priv->regs->if1_mcont,
+                                         CAN_IF_MCONT_MSGLOST);
+                       iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL,
+                                 &priv->regs->if1_cmask);
+                       pch_can_check_if_busy(&priv->regs->if1_creq, k);
+
+                       skb = alloc_can_err_skb(ndev, &cf);
+                       if (!skb)
+                               return -ENOMEM;
+
+                       priv->can.can_stats.error_passive++;
+                       priv->can.state = CAN_STATE_ERROR_PASSIVE;
+                       cf->can_id |= CAN_ERR_CRTL;
+                       cf->data[1] |= CAN_ERR_CRTL_RX_OVERFLOW;
+                       cf->data[2] |= CAN_ERR_PROT_OVERLOAD;
+                       stats->rx_packets++;
+                       stats->rx_bytes += cf->can_dlc;
+
+                       netif_receive_skb(skb);
+                       rcv_pkts++;
+                       goto RX_NEXT;
+               }
+               if (!(reg & CAN_IF_MCONT_NEWDAT))
+                       goto RX_NEXT;
+
+               skb = alloc_can_skb(priv->ndev, &cf);
+               if (!skb)
+                       return -ENOMEM;
+
+               /* Get Received data */
+               ide = ((ioread32(&priv->regs->if1_id2)) & CAN_ID2_XTD) >> 14;
+               if (ide) {
+                       id = (ioread32(&priv->regs->if1_id1) & 0xffff);
+                       id |= (((ioread32(&priv->regs->if1_id2)) &
+                                           0x1fff) << 16);
+                       cf->can_id = (id & CAN_EFF_MASK) | CAN_EFF_FLAG;
+               } else {
+                       id = (((ioread32(&priv->regs->if1_id2)) &
+                                         (CAN_SFF_MASK << 2)) >> 2);
+                       cf->can_id = (id & CAN_SFF_MASK);
+               }
+
+               rtr = (ioread32(&priv->regs->if1_id2) &  CAN_ID2_DIR);
+               if (rtr) {
+                       cf->can_dlc = 0;
+                       cf->can_id |= CAN_RTR_FLAG;
+               } else {
+                       cf->can_dlc = ((ioread32(&priv->regs->if1_mcont)) &
+                                                  0x0f);
+               }
+
+               for (i = 0, j = 0; i < cf->can_dlc; j++) {
+                       reg = ioread32(&priv->regs->if1_dataa1 + j*4);
+                       cf->data[i++] = cpu_to_le32(reg & 0xff);
+                       if (i == cf->can_dlc)
+                               break;
+                       cf->data[i++] = cpu_to_le32((reg >> 8) & 0xff);
+               }
+
+               netif_receive_skb(skb);
+               rcv_pkts++;
+               stats->rx_packets++;
+               stats->rx_bytes += cf->can_dlc;
+
+               if (k < PCH_FIFO_THRESH) {
+                       iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL |
+                                 CAN_CMASK_ARB, &priv->regs->if1_cmask);
+
+                       /* Clearing the Dir bit. */
+                       pch_can_bit_clear(&priv->regs->if1_id2, CAN_ID2_DIR);
+
+                       /* Clearing NewDat & IntPnd */
+                       pch_can_bit_clear(&priv->regs->if1_mcont,
+                                         CAN_IF_MCONT_INTPND);
+                       pch_can_check_if_busy(&priv->regs->if1_creq, k);
+               } else if (k > PCH_FIFO_THRESH) {
+                       pch_can_int_clr(priv, k);
+               } else if (k == PCH_FIFO_THRESH) {
+                       int cnt;
+                       for (cnt = 0; cnt < PCH_FIFO_THRESH; cnt++)
+                               pch_can_int_clr(priv, cnt+1);
+               }
+RX_NEXT:
+               /* Reading the messsage object from the Message RAM */
+               iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
+               pch_can_check_if_busy(&priv->regs->if1_creq, k + 1);
+               reg = ioread32(&priv->regs->if1_mcont);
+       }
+
+       return rcv_pkts;
+}
+static int pch_can_rx_poll(struct napi_struct *napi, int quota)
+{
+       struct net_device *ndev = napi->dev;
+       struct pch_can_priv *priv = netdev_priv(ndev);
+       struct net_device_stats *stats = &(priv->ndev->stats);
+       u32 dlc;
+       u32 int_stat;
+       int rcv_pkts = 0;
+       u32 reg_stat;
+       unsigned long flags;
+
+       int_stat = pch_can_int_pending(priv);
+       if (!int_stat)
+               return 0;
+
+INT_STAT:
+       if (int_stat == CAN_STATUS_INT) {
+               reg_stat = ioread32(&priv->regs->stat);
+               if (reg_stat & (PCH_BUS_OFF | PCH_LEC_ALL)) {
+                       if ((reg_stat & PCH_LEC_ALL) != PCH_LEC_ALL)
+                               pch_can_error(ndev, reg_stat);
+               }
+
+               if (reg_stat & PCH_TX_OK) {
+                       spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+                       iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
+                       pch_can_check_if_busy(&priv->regs->if2_creq,
+                                              ioread32(&priv->regs->intr));
+                       spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+                       pch_can_bit_clear(&priv->regs->stat, PCH_TX_OK);
+               }
+
+               if (reg_stat & PCH_RX_OK)
+                       pch_can_bit_clear(&priv->regs->stat, PCH_RX_OK);
+
+               int_stat = pch_can_int_pending(priv);
+               if (int_stat == CAN_STATUS_INT)
+                       goto INT_STAT;
+       }
+
+MSG_OBJ:
+       if ((int_stat >= 1) && (int_stat <= PCH_RX_OBJ_NUM)) {
+               spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+               rcv_pkts = pch_can_rx_normal(ndev, int_stat);
+               spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+               if (rcv_pkts < 0)
+                       return 0;
+       } else if ((int_stat > PCH_RX_OBJ_NUM) && (int_stat <= PCH_OBJ_NUM)) {
+               if (priv->msg_obj[int_stat - 1] == MSG_OBJ_TX) {
+                       /* Handle transmission interrupt */
+                       can_get_echo_skb(ndev, int_stat - PCH_RX_OBJ_NUM - 1);
+                       spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+                       iowrite32(CAN_CMASK_RX_TX_GET | CAN_CMASK_CLRINTPND,
+                                 &priv->regs->if2_cmask);
+                       dlc = ioread32(&priv->regs->if2_mcont) &
+                                      CAN_IF_MCONT_DLC;
+                       pch_can_check_if_busy(&priv->regs->if2_creq, int_stat);
+                       spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+                       if (dlc > 8)
+                               dlc = 8;
+                       stats->tx_bytes += dlc;
+                       stats->tx_packets++;
+               }
+       }
+
+       int_stat = pch_can_int_pending(priv);
+       if (int_stat == CAN_STATUS_INT)
+               goto INT_STAT;
+       else if (int_stat >= 1 && int_stat <= 32)
+               goto MSG_OBJ;
+
+       napi_complete(napi);
+       pch_can_set_int_enables(priv, PCH_CAN_ALL);
+
+       return rcv_pkts;
+}
+
+static int pch_set_bittiming(struct net_device *ndev)
+{
+       struct pch_can_priv *priv = netdev_priv(ndev);
+       const struct can_bittiming *bt = &priv->can.bittiming;
+       u32 canbit;
+       u32 bepe;
+       u32 brp;
+
+       /* Setting the CCE bit for accessing the Can Timing register. */
+       pch_can_bit_set(&priv->regs->cont, CAN_CTRL_CCE);
+
+       brp = (bt->tq) / (1000000000/PCH_CAN_CLK) - 1;
+       canbit = brp & MSK_BITT_BRP;
+       canbit |= (bt->sjw - 1) << BIT_BITT_SJW;
+       canbit |= (bt->phase_seg1 + bt->prop_seg - 1) << BIT_BITT_TSEG1;
+       canbit |= (bt->phase_seg2 - 1) << BIT_BITT_TSEG2;
+       bepe = (brp & MSK_BRPE_BRPE) >> BIT_BRPE_BRPE;
+       iowrite32(canbit, &priv->regs->bitt);
+       iowrite32(bepe, &priv->regs->brpe);
+       pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_CCE);
+
+       return 0;
+}
+
+static void pch_can_start(struct net_device *ndev)
+{
+       struct pch_can_priv *priv = netdev_priv(ndev);
+
+       if (priv->can.state != CAN_STATE_STOPPED)
+               pch_can_reset(priv);
+
+       pch_set_bittiming(ndev);
+       pch_can_set_optmode(priv);
+
+       pch_can_tx_enable_all(priv);
+       pch_can_rx_enable_all(priv);
+
+       /* Setting the CAN to run mode. */
+       pch_can_set_run_mode(priv, PCH_CAN_RUN);
+
+       priv->can.state = CAN_STATE_ERROR_ACTIVE;
+
+       return;
+}
+
+static int pch_can_do_set_mode(struct net_device *ndev, enum can_mode mode)
+{
+       int ret = 0;
+
+       switch (mode) {
+       case CAN_MODE_START:
+               pch_can_start(ndev);
+               netif_wake_queue(ndev);
+               break;
+       default:
+               ret = -EOPNOTSUPP;
+               break;
+       }
+
+       return ret;
+}
+
+static int pch_can_open(struct net_device *ndev)
+{
+       struct pch_can_priv *priv = netdev_priv(ndev);
+       int retval;
+
+       retval = pci_enable_msi(priv->dev);
+       if (retval) {
+               dev_info(&ndev->dev, "PCH CAN opened without MSI\n");
+               priv->use_msi = 0;
+       } else {
+               dev_info(&ndev->dev, "PCH CAN opened with MSI\n");
+               priv->use_msi = 1;
+       }
+
+       /* Regsitering the interrupt. */
+       retval = request_irq(priv->dev->irq, pch_can_interrupt, IRQF_SHARED,
+                            ndev->name, ndev);
+       if (retval) {
+               dev_err(&ndev->dev, "request_irq failed.\n");
+               goto req_irq_err;
+       }
+
+       /* Open common can device */
+       retval = open_candev(ndev);
+       if (retval) {
+               dev_err(ndev->dev.parent, "open_candev() failed %d\n", retval);
+               goto err_open_candev;
+       }
+
+       pch_can_init(priv);
+       pch_can_start(ndev);
+       napi_enable(&priv->napi);
+       netif_start_queue(ndev);
+
+       return 0;
+
+err_open_candev:
+       free_irq(priv->dev->irq, ndev);
+req_irq_err:
+       if (priv->use_msi)
+               pci_disable_msi(priv->dev);
+
+       pch_can_release(priv);
+
+       return retval;
+}
+
+static int pch_close(struct net_device *ndev)
+{
+       struct pch_can_priv *priv = netdev_priv(ndev);
+
+       netif_stop_queue(ndev);
+       napi_disable(&priv->napi);
+       pch_can_release(priv);
+       free_irq(priv->dev->irq, ndev);
+       if (priv->use_msi)
+               pci_disable_msi(priv->dev);
+       close_candev(ndev);
+       priv->can.state = CAN_STATE_STOPPED;
+       return 0;
+}
+
+static int pch_get_msg_obj_sts(struct net_device *ndev, u32 obj_id)
+{
+       u32 buffer_status = 0;
+       struct pch_can_priv *priv = netdev_priv(ndev);
+
+       /* Getting the message object status. */
+       buffer_status = (u32) pch_can_get_buffer_status(priv);
+
+       return buffer_status & obj_id;
+}
+
+
+static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev)
+{
+       int i, j;
+       unsigned long flags;
+       struct pch_can_priv *priv = netdev_priv(ndev);
+       struct can_frame *cf = (struct can_frame *)skb->data;
+       int tx_buffer_avail = 0;
+
+       if (can_dropped_invalid_skb(ndev, skb))
+               return NETDEV_TX_OK;
+
+       if (priv->tx_obj == (PCH_OBJ_NUM + 1)) { /* Point tail Obj */
+               while (pch_get_msg_obj_sts(ndev, (((1 << PCH_TX_OBJ_NUM)-1) <<
+                                          PCH_RX_OBJ_NUM)))
+                       udelay(500);
+
+               priv->tx_obj = PCH_RX_OBJ_NUM + 1; /* Point head of Tx Obj ID */
+               tx_buffer_avail = priv->tx_obj; /* Point Tail of Tx Obj */
+       } else {
+               tx_buffer_avail = priv->tx_obj;
+       }
+       priv->tx_obj++;
+
+       /* Attaining the lock. */
+       spin_lock_irqsave(&priv->msgif_reg_lock, flags);
+
+       /* Reading the Msg Obj from the Msg RAM to the Interface register. */
+       iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
+       pch_can_check_if_busy(&priv->regs->if2_creq, tx_buffer_avail);
+
+       /* Setting the CMASK register. */
+       pch_can_bit_set(&priv->regs->if2_cmask, CAN_CMASK_ALL);
+
+       /* If ID extended is set. */
+       pch_can_bit_clear(&priv->regs->if2_id1, 0xffff);
+       pch_can_bit_clear(&priv->regs->if2_id2, 0x1fff | CAN_ID2_XTD);
+       if (cf->can_id & CAN_EFF_FLAG) {
+               pch_can_bit_set(&priv->regs->if2_id1, cf->can_id & 0xffff);
+               pch_can_bit_set(&priv->regs->if2_id2,
+                               ((cf->can_id >> 16) & 0x1fff) | CAN_ID2_XTD);
+       } else {
+               pch_can_bit_set(&priv->regs->if2_id1, 0);
+               pch_can_bit_set(&priv->regs->if2_id2,
+                               (cf->can_id & CAN_SFF_MASK) << 2);
+       }
+
+       /* If remote frame has to be transmitted.. */
+       if (cf->can_id & CAN_RTR_FLAG)
+               pch_can_bit_clear(&priv->regs->if2_id2, CAN_ID2_DIR);
+
+       for (i = 0, j = 0; i < cf->can_dlc; j++) {
+               iowrite32(le32_to_cpu(cf->data[i++]),
+                        (&priv->regs->if2_dataa1) + j*4);
+               if (i == cf->can_dlc)
+                       break;
+               iowrite32(le32_to_cpu(cf->data[i++] << 8),
+                        (&priv->regs->if2_dataa1) + j*4);
+       }
+
+       can_put_echo_skb(skb, ndev, tx_buffer_avail - PCH_RX_OBJ_NUM - 1);
+
+       /* Updating the size of the data. */
+       pch_can_bit_clear(&priv->regs->if2_mcont, 0x0f);
+       pch_can_bit_set(&priv->regs->if2_mcont, cf->can_dlc);
+
+       /* Clearing IntPend, NewDat & TxRqst */
+       pch_can_bit_clear(&priv->regs->if2_mcont,
+                         CAN_IF_MCONT_NEWDAT | CAN_IF_MCONT_INTPND |
+                         CAN_IF_MCONT_TXRQXT);
+
+       /* Setting NewDat, TxRqst bits */
+       pch_can_bit_set(&priv->regs->if2_mcont,
+                       CAN_IF_MCONT_NEWDAT | CAN_IF_MCONT_TXRQXT);
+
+       pch_can_check_if_busy(&priv->regs->if2_creq, tx_buffer_avail);
+
+       spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
+
+       return NETDEV_TX_OK;
+}
+
+static const struct net_device_ops pch_can_netdev_ops = {
+       .ndo_open               = pch_can_open,
+       .ndo_stop               = pch_close,
+       .ndo_start_xmit         = pch_xmit,
+};
+
+static void __devexit pch_can_remove(struct pci_dev *pdev)
+{
+       struct net_device *ndev = pci_get_drvdata(pdev);
+       struct pch_can_priv *priv = netdev_priv(ndev);
+
+       unregister_candev(priv->ndev);
+       free_candev(priv->ndev);
+       pci_iounmap(pdev, priv->regs);
+       pci_release_regions(pdev);
+       pci_disable_device(pdev);
+       pci_set_drvdata(pdev, NULL);
+       pch_can_reset(priv);
+}
+
+#ifdef CONFIG_PM
+static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+       int i;                  /* Counter variable. */
+       int retval;             /* Return value. */
+       u32 buf_stat;   /* Variable for reading the transmit buffer status. */
+       u32 counter = 0xFFFFFF;
+
+       struct net_device *dev = pci_get_drvdata(pdev);
+       struct pch_can_priv *priv = netdev_priv(dev);
+
+       /* Stop the CAN controller */
+       pch_can_set_run_mode(priv, PCH_CAN_STOP);
+
+       /* Indicate that we are aboutto/in suspend */
+       priv->can.state = CAN_STATE_SLEEPING;
+
+       /* Waiting for all transmission to complete. */
+       while (counter) {
+               buf_stat = pch_can_get_buffer_status(priv);
+               if (!buf_stat)
+                       break;
+               counter--;
+               udelay(1);
+       }
+       if (!counter)
+               dev_err(&pdev->dev, "%s -> Transmission time out.\n", __func__);
+
+       /* Save interrupt configuration and then disable them */
+       pch_can_get_int_enables(priv, &(priv->int_enables));
+       pch_can_set_int_enables(priv, PCH_CAN_DISABLE);
+
+       /* Save Tx buffer enable state */
+       for (i = 0; i < PCH_OBJ_NUM; i++) {
+               if (priv->msg_obj[i] == MSG_OBJ_TX)
+                       pch_can_get_tx_enable(priv, i + 1,
+                                             &(priv->tx_enable[i]));
+       }
+
+       /* Disable all Transmit buffers */
+       pch_can_tx_disable_all(priv);
+
+       /* Save Rx buffer enable state */
+       for (i = 0; i < PCH_OBJ_NUM; i++) {
+               if (priv->msg_obj[i] == MSG_OBJ_RX) {
+                       pch_can_get_rx_enable(priv, i + 1,
+                                               &(priv->rx_enable[i]));
+                       pch_can_get_rx_buffer_link(priv, i + 1,
+                                               &(priv->rx_link[i]));
+               }
+       }
+
+       /* Disable all Receive buffers */
+       pch_can_rx_disable_all(priv);
+       retval = pci_save_state(pdev);
+       if (retval) {
+               dev_err(&pdev->dev, "pci_save_state failed.\n");
+       } else {
+               pci_enable_wake(pdev, PCI_D3hot, 0);
+               pci_disable_device(pdev);
+               pci_set_power_state(pdev, pci_choose_state(pdev, state));
+       }
+
+       return retval;
+}
+
+static int pch_can_resume(struct pci_dev *pdev)
+{
+       int i;                  /* Counter variable. */
+       int retval;             /* Return variable. */
+       struct net_device *dev = pci_get_drvdata(pdev);
+       struct pch_can_priv *priv = netdev_priv(dev);
+
+       pci_set_power_state(pdev, PCI_D0);
+       pci_restore_state(pdev);
+       retval = pci_enable_device(pdev);
+       if (retval) {
+               dev_err(&pdev->dev, "pci_enable_device failed.\n");
+               return retval;
+       }
+
+       pci_enable_wake(pdev, PCI_D3hot, 0);
+
+       priv->can.state = CAN_STATE_ERROR_ACTIVE;
+
+       /* Disabling all interrupts. */
+       pch_can_set_int_enables(priv, PCH_CAN_DISABLE);
+
+       /* Setting the CAN device in Stop Mode. */
+       pch_can_set_run_mode(priv, PCH_CAN_STOP);
+
+       /* Configuring the transmit and receive buffers. */
+       pch_can_config_rx_tx_buffers(priv);
+
+       /* Restore the CAN state */
+       pch_set_bittiming(dev);
+
+       /* Listen/Active */
+       pch_can_set_optmode(priv);
+
+       /* Enabling the transmit buffer. */
+       for (i = 0; i < PCH_OBJ_NUM; i++) {
+               if (priv->msg_obj[i] == MSG_OBJ_TX) {
+                       pch_can_set_tx_enable(priv, i + 1,
+                                             priv->tx_enable[i]);
+               }
+       }
+
+       /* Configuring the receive buffer and enabling them. */
+       for (i = 0; i < PCH_OBJ_NUM; i++) {
+               if (priv->msg_obj[i] == MSG_OBJ_RX) {
+                       /* Restore buffer link */
+                       pch_can_set_rx_buffer_link(priv, i + 1,
+                                                  priv->rx_link[i]);
+
+                       /* Restore buffer enables */
+                       pch_can_set_rx_enable(priv, i + 1, priv->rx_enable[i]);
+               }
+       }
+
+       /* Enable CAN Interrupts */
+       pch_can_set_int_custom(priv);
+
+       /* Restore Run Mode */
+       pch_can_set_run_mode(priv, PCH_CAN_RUN);
+
+       return retval;
+}
+#else
+#define pch_can_suspend NULL
+#define pch_can_resume NULL
+#endif
+
+static int pch_can_get_berr_counter(const struct net_device *dev,
+                                   struct can_berr_counter *bec)
+{
+       struct pch_can_priv *priv = netdev_priv(dev);
+
+       bec->txerr = ioread32(&priv->regs->errc) & CAN_TEC;
+       bec->rxerr = (ioread32(&priv->regs->errc) & CAN_REC) >> 8;
+
+       return 0;
+}
+
+static int __devinit pch_can_probe(struct pci_dev *pdev,
+                                  const struct pci_device_id *id)
+{
+       struct net_device *ndev;
+       struct pch_can_priv *priv;
+       int rc;
+       int index;
+       void __iomem *addr;
+
+       rc = pci_enable_device(pdev);
+       if (rc) {
+               dev_err(&pdev->dev, "Failed pci_enable_device %d\n", rc);
+               goto probe_exit_endev;
+       }
+
+       rc = pci_request_regions(pdev, KBUILD_MODNAME);
+       if (rc) {
+               dev_err(&pdev->dev, "Failed pci_request_regions %d\n", rc);
+               goto probe_exit_pcireq;
+       }
+
+       addr = pci_iomap(pdev, 1, 0);
+       if (!addr) {
+               rc = -EIO;
+               dev_err(&pdev->dev, "Failed pci_iomap\n");
+               goto probe_exit_ipmap;
+       }
+
+       ndev = alloc_candev(sizeof(struct pch_can_priv), PCH_TX_OBJ_NUM);
+       if (!ndev) {
+               rc = -ENOMEM;
+               dev_err(&pdev->dev, "Failed alloc_candev\n");
+               goto probe_exit_alloc_candev;
+       }
+
+       priv = netdev_priv(ndev);
+       priv->ndev = ndev;
+       priv->regs = addr;
+       priv->dev = pdev;
+       priv->can.bittiming_const = &pch_can_bittiming_const;
+       priv->can.do_set_mode = pch_can_do_set_mode;
+       priv->can.do_get_berr_counter = pch_can_get_berr_counter;
+       priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY |
+                                      CAN_CTRLMODE_LOOPBACK;
+       priv->tx_obj = PCH_RX_OBJ_NUM + 1; /* Point head of Tx Obj */
+
+       ndev->irq = pdev->irq;
+       ndev->flags |= IFF_ECHO;
+
+       pci_set_drvdata(pdev, ndev);
+       SET_NETDEV_DEV(ndev, &pdev->dev);
+       ndev->netdev_ops = &pch_can_netdev_ops;
+
+       priv->can.clock.freq = PCH_CAN_CLK; /* Hz */
+       for (index = 0; index < PCH_RX_OBJ_NUM;)
+               priv->msg_obj[index++] = MSG_OBJ_RX;
+
+       for (index = index;  index < PCH_OBJ_NUM;)
+               priv->msg_obj[index++] = MSG_OBJ_TX;
+
+       netif_napi_add(ndev, &priv->napi, pch_can_rx_poll, PCH_RX_OBJ_NUM);
+
+       rc = register_candev(ndev);
+       if (rc) {
+               dev_err(&pdev->dev, "Failed register_candev %d\n", rc);
+               goto probe_exit_reg_candev;
+       }
+
+       return 0;
+
+probe_exit_reg_candev:
+       free_candev(ndev);
+probe_exit_alloc_candev:
+       pci_iounmap(pdev, addr);
+probe_exit_ipmap:
+       pci_release_regions(pdev);
+probe_exit_pcireq:
+       pci_disable_device(pdev);
+probe_exit_endev:
+       return rc;
+}
+
+static struct pci_driver pch_can_pcidev = {
+       .name = "pch_can",
+       .id_table = pch_pci_tbl,
+       .probe = pch_can_probe,
+       .remove = __devexit_p(pch_can_remove),
+       .suspend = pch_can_suspend,
+       .resume = pch_can_resume,
+};
+
+static int __init pch_can_pci_init(void)
+{
+       return pci_register_driver(&pch_can_pcidev);
+}
+module_init(pch_can_pci_init);
+
+static void __exit pch_can_pci_exit(void)
+{
+       pci_unregister_driver(&pch_can_pcidev);
+}
+module_exit(pch_can_pci_exit);
+
+MODULE_DESCRIPTION("Controller Area Network Driver");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION("0.94");
index ae3505afd682ccf58a9bd09dc6112ae83eaf96c4..6fdc031daaae18b23397b64e152d5162725d992c 100644 (file)
@@ -58,4 +58,16 @@ config CAN_PLX_PCI
           - esd CAN-PCIe/2000
           - Marathon CAN-bus-PCI card (http://www.marathon.ru/)
           - TEWS TECHNOLOGIES TPMC810 card (http://www.tews.com/)
+
+config CAN_TSCAN1
+       tristate "TS-CAN1 PC104 boards"
+       depends on ISA
+       help
+       This driver is for Technologic Systems' TSCAN-1 PC104 boards.
+       http://www.embeddedarm.com/products/board-detail.php?product=TS-CAN1
+       The driver supports multiple boards and automatically configures them:
+       PLD IO base addresses are read from jumpers JP1 and JP2,
+       IRQ numbers are read from jumpers JP4 and JP5,
+       SJA1000 IO base addresses are chosen heuristically (first that works).
+
 endif
index ce924553995d5d850c73f4e865a189f685795b18..2c591eb321c7987f0b55f0852727eba7f1b36192 100644 (file)
@@ -9,5 +9,6 @@ obj-$(CONFIG_CAN_SJA1000_OF_PLATFORM) += sja1000_of_platform.o
 obj-$(CONFIG_CAN_EMS_PCI) += ems_pci.o
 obj-$(CONFIG_CAN_KVASER_PCI) += kvaser_pci.o
 obj-$(CONFIG_CAN_PLX_PCI) += plx_pci.o
+obj-$(CONFIG_CAN_TSCAN1) += tscan1.o
 
 ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/sja1000/tscan1.c b/drivers/net/can/sja1000/tscan1.c
new file mode 100644 (file)
index 0000000..9756099
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * tscan1.c: driver for Technologic Systems TS-CAN1 PC104 boards
+ *
+ * Copyright 2010 Andre B. Oliveira
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * References:
+ * - Getting started with TS-CAN1, Technologic Systems, Jun 2009
+ *     http://www.embeddedarm.com/documentation/ts-can1-manual.pdf
+ */
+
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/isa.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include "sja1000.h"
+
+MODULE_DESCRIPTION("Driver for Technologic Systems TS-CAN1 PC104 boards");
+MODULE_AUTHOR("Andre B. Oliveira <anbadeol@gmail.com>");
+MODULE_LICENSE("GPL");
+
+/* Maximum number of boards (one in each JP1:JP2 setting of IO address) */
+#define TSCAN1_MAXDEV 4
+
+/* PLD registers address offsets */
+#define TSCAN1_ID1     0
+#define TSCAN1_ID2     1
+#define TSCAN1_VERSION 2
+#define TSCAN1_LED     3
+#define TSCAN1_PAGE    4
+#define TSCAN1_MODE    5
+#define TSCAN1_JUMPERS 6
+
+/* PLD board identifier registers magic values */
+#define TSCAN1_ID1_VALUE 0xf6
+#define TSCAN1_ID2_VALUE 0xb9
+
+/* PLD mode register SJA1000 IO enable bit */
+#define TSCAN1_MODE_ENABLE 0x40
+
+/* PLD jumpers register bits */
+#define TSCAN1_JP4 0x10
+#define TSCAN1_JP5 0x20
+
+/* PLD IO base addresses start */
+#define TSCAN1_PLD_ADDRESS 0x150
+
+/* PLD register space size */
+#define TSCAN1_PLD_SIZE 8
+
+/* SJA1000 register space size */
+#define TSCAN1_SJA1000_SIZE 32
+
+/* SJA1000 crystal frequency (16MHz) */
+#define TSCAN1_SJA1000_XTAL 16000000
+
+/* SJA1000 IO base addresses */
+static const unsigned short tscan1_sja1000_addresses[] __devinitconst = {
+       0x100, 0x120, 0x180, 0x1a0, 0x200, 0x240, 0x280, 0x320
+};
+
+/* Read SJA1000 register */
+static u8 tscan1_read(const struct sja1000_priv *priv, int reg)
+{
+       return inb((unsigned long)priv->reg_base + reg);
+}
+
+/* Write SJA1000 register */
+static void tscan1_write(const struct sja1000_priv *priv, int reg, u8 val)
+{
+       outb(val, (unsigned long)priv->reg_base + reg);
+}
+
+/* Probe for a TS-CAN1 board with JP2:JP1 jumper setting ID */
+static int __devinit tscan1_probe(struct device *dev, unsigned id)
+{
+       struct net_device *netdev;
+       struct sja1000_priv *priv;
+       unsigned long pld_base, sja1000_base;
+       int irq, i;
+
+       pld_base = TSCAN1_PLD_ADDRESS + id * TSCAN1_PLD_SIZE;
+       if (!request_region(pld_base, TSCAN1_PLD_SIZE, dev_name(dev)))
+               return -EBUSY;
+
+       if (inb(pld_base + TSCAN1_ID1) != TSCAN1_ID1_VALUE ||
+           inb(pld_base + TSCAN1_ID2) != TSCAN1_ID2_VALUE) {
+               release_region(pld_base, TSCAN1_PLD_SIZE);
+               return -ENODEV;
+       }
+
+       switch (inb(pld_base + TSCAN1_JUMPERS) & (TSCAN1_JP4 | TSCAN1_JP5)) {
+       case TSCAN1_JP4:
+               irq = 6;
+               break;
+       case TSCAN1_JP5:
+               irq = 7;
+               break;
+       case TSCAN1_JP4 | TSCAN1_JP5:
+               irq = 5;
+               break;
+       default:
+               dev_err(dev, "invalid JP4:JP5 setting (no IRQ)\n");
+               release_region(pld_base, TSCAN1_PLD_SIZE);
+               return -EINVAL;
+       }
+
+       netdev = alloc_sja1000dev(0);
+       if (!netdev) {
+               release_region(pld_base, TSCAN1_PLD_SIZE);
+               return -ENOMEM;
+       }
+
+       dev_set_drvdata(dev, netdev);
+       SET_NETDEV_DEV(netdev, dev);
+
+       netdev->base_addr = pld_base;
+       netdev->irq = irq;
+
+       priv = netdev_priv(netdev);
+       priv->read_reg = tscan1_read;
+       priv->write_reg = tscan1_write;
+       priv->can.clock.freq = TSCAN1_SJA1000_XTAL / 2;
+       priv->cdr = CDR_CBP | CDR_CLK_OFF;
+       priv->ocr = OCR_TX0_PUSHPULL;
+
+       /* Select the first SJA1000 IO address that is free and that works */
+       for (i = 0; i < ARRAY_SIZE(tscan1_sja1000_addresses); i++) {
+               sja1000_base = tscan1_sja1000_addresses[i];
+               if (!request_region(sja1000_base, TSCAN1_SJA1000_SIZE,
+                                                               dev_name(dev)))
+                       continue;
+
+               /* Set SJA1000 IO base address and enable it */
+               outb(TSCAN1_MODE_ENABLE | i, pld_base + TSCAN1_MODE);
+
+               priv->reg_base = (void __iomem *)sja1000_base;
+               if (!register_sja1000dev(netdev)) {
+                       /* SJA1000 probe succeeded; turn LED off and return */
+                       outb(0, pld_base + TSCAN1_LED);
+                       netdev_info(netdev, "TS-CAN1 at 0x%lx 0x%lx irq %d\n",
+                                               pld_base, sja1000_base, irq);
+                       return 0;
+               }
+
+               /* SJA1000 probe failed; release and try next address */
+               outb(0, pld_base + TSCAN1_MODE);
+               release_region(sja1000_base, TSCAN1_SJA1000_SIZE);
+       }
+
+       dev_err(dev, "failed to assign SJA1000 IO address\n");
+       dev_set_drvdata(dev, NULL);
+       free_sja1000dev(netdev);
+       release_region(pld_base, TSCAN1_PLD_SIZE);
+       return -ENXIO;
+}
+
+static int __devexit tscan1_remove(struct device *dev, unsigned id /*unused*/)
+{
+       struct net_device *netdev;
+       struct sja1000_priv *priv;
+       unsigned long pld_base, sja1000_base;
+
+       netdev = dev_get_drvdata(dev);
+       unregister_sja1000dev(netdev);
+       dev_set_drvdata(dev, NULL);
+
+       priv = netdev_priv(netdev);
+       pld_base = netdev->base_addr;
+       sja1000_base = (unsigned long)priv->reg_base;
+
+       outb(0, pld_base + TSCAN1_MODE);        /* disable SJA1000 IO space */
+
+       release_region(sja1000_base, TSCAN1_SJA1000_SIZE);
+       release_region(pld_base, TSCAN1_PLD_SIZE);
+
+       free_sja1000dev(netdev);
+
+       return 0;
+}
+
+static struct isa_driver tscan1_isa_driver = {
+       .probe = tscan1_probe,
+       .remove = __devexit_p(tscan1_remove),
+       .driver = {
+               .name = "tscan1",
+       },
+};
+
+static int __init tscan1_init(void)
+{
+       return isa_register_driver(&tscan1_isa_driver, TSCAN1_MAXDEV);
+}
+module_init(tscan1_init);
+
+static void __exit tscan1_exit(void)
+{
+       isa_unregister_driver(&tscan1_isa_driver);
+}
+module_exit(tscan1_exit);
index a04ce6a5f637142a1aba4cb933c03bb8485cd5ec..4e3c12371aaecea6de7e3057b6f8b4713387355f 100644 (file)
@@ -1266,11 +1266,13 @@ static int cxgb_up(struct adapter *adap)
        }
 
        if (!(adap->flags & QUEUES_BOUND)) {
-               err = bind_qsets(adap);
-               if (err) {
-                       CH_ERR(adap, "failed to bind qsets, err %d\n", err);
+               int ret = bind_qsets(adap);
+
+               if (ret < 0) {
+                       CH_ERR(adap, "failed to bind qsets, err %d\n", ret);
                        t3_intr_disable(adap);
                        free_irq_resources(adap);
+                       err = ret;
                        goto out;
                }
                adap->flags |= QUEUES_BOUND;
index eaa49e4119f146c047903a37dfda408086910faa..3d4253d311eb50972c3037fb5e7b52ef2b18395b 100644 (file)
@@ -281,7 +281,6 @@ struct sge_rspq;
 
 struct port_info {
        struct adapter *adapter;
-       struct vlan_group *vlan_grp;
        u16    viid;
        s16    xact_addr_filt;        /* index of exact MAC address filter */
        u16    rss_size;              /* size of VI's RSS table slice */
index 87054e0a57467841be71bcb3e3cfc7517c54bbe8..f17703f410b3673a096aec05f9085329650c5c52 100644 (file)
@@ -403,7 +403,7 @@ static int link_start(struct net_device *dev)
         * that step explicitly.
         */
        ret = t4_set_rxmode(pi->adapter, mb, pi->viid, dev->mtu, -1, -1, -1,
-                           pi->vlan_grp != NULL, true);
+                           !!(dev->features & NETIF_F_HW_VLAN_RX), true);
        if (ret == 0) {
                ret = t4_change_mac(pi->adapter, mb, pi->viid,
                                    pi->xact_addr_filt, dev->dev_addr, true,
@@ -1881,7 +1881,24 @@ static int set_tso(struct net_device *dev, u32 value)
 
 static int set_flags(struct net_device *dev, u32 flags)
 {
-       return ethtool_op_set_flags(dev, flags, ETH_FLAG_RXHASH);
+       int err;
+       unsigned long old_feat = dev->features;
+
+       err = ethtool_op_set_flags(dev, flags, ETH_FLAG_RXHASH |
+                                  ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN);
+       if (err)
+               return err;
+
+       if ((old_feat ^ dev->features) & NETIF_F_HW_VLAN_RX) {
+               const struct port_info *pi = netdev_priv(dev);
+
+               err = t4_set_rxmode(pi->adapter, pi->adapter->fn, pi->viid, -1,
+                                   -1, -1, -1, !!(flags & ETH_FLAG_RXVLAN),
+                                   true);
+               if (err)
+                       dev->features = old_feat;
+       }
+       return err;
 }
 
 static int get_rss_table(struct net_device *dev, struct ethtool_rxfh_indir *p)
@@ -2842,15 +2859,6 @@ static int cxgb_set_mac_addr(struct net_device *dev, void *p)
        return 0;
 }
 
-static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
-{
-       struct port_info *pi = netdev_priv(dev);
-
-       pi->vlan_grp = grp;
-       t4_set_rxmode(pi->adapter, pi->adapter->fn, pi->viid, -1, -1, -1, -1,
-                     grp != NULL, true);
-}
-
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static void cxgb_netpoll(struct net_device *dev)
 {
@@ -2878,7 +2886,6 @@ static const struct net_device_ops cxgb4_netdev_ops = {
        .ndo_validate_addr    = eth_validate_addr,
        .ndo_do_ioctl         = cxgb_ioctl,
        .ndo_change_mtu       = cxgb_change_mtu,
-       .ndo_vlan_rx_register = vlan_rx_register,
 #ifdef CONFIG_NET_POLL_CONTROLLER
        .ndo_poll_controller  = cxgb_netpoll,
 #endif
@@ -3658,7 +3665,6 @@ static int __devinit init_one(struct pci_dev *pdev,
                pi->rx_offload = RX_CSO;
                pi->port_id = i;
                netif_carrier_off(netdev);
-               netif_tx_stop_all_queues(netdev);
                netdev->irq = pdev->irq;
 
                netdev->features |= NETIF_F_SG | TSO_FLAGS;
@@ -3730,6 +3736,7 @@ static int __devinit init_one(struct pci_dev *pdev,
 
                        __set_bit(i, &adapter->registered_device_map);
                        adapter->chan_map[adap2pinfo(adapter, i)->tx_chan] = i;
+                       netif_tx_stop_all_queues(adapter->port[i]);
                }
        }
        if (!adapter->registered_device_map) {
index 9967f3debce7e1010bd6ff58df5d6ad2060543d3..17022258ed689101e940ce977c57a4c5540f9e98 100644 (file)
@@ -1530,18 +1530,11 @@ static void do_gro(struct sge_eth_rxq *rxq, const struct pkt_gl *gl,
                skb->rxhash = (__force u32)pkt->rsshdr.hash_val;
 
        if (unlikely(pkt->vlan_ex)) {
-               struct port_info *pi = netdev_priv(rxq->rspq.netdev);
-               struct vlan_group *grp = pi->vlan_grp;
-
+               __vlan_hwaccel_put_tag(skb, ntohs(pkt->vlan));
                rxq->stats.vlan_ex++;
-               if (likely(grp)) {
-                       ret = vlan_gro_frags(&rxq->rspq.napi, grp,
-                                            ntohs(pkt->vlan));
-                       goto stats;
-               }
        }
        ret = napi_gro_frags(&rxq->rspq.napi);
-stats: if (ret == GRO_HELD)
+       if (ret == GRO_HELD)
                rxq->stats.lro_pkts++;
        else if (ret == GRO_MERGED || ret == GRO_MERGED_FREE)
                rxq->stats.lro_merged++;
@@ -1608,16 +1601,10 @@ int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
                skb_checksum_none_assert(skb);
 
        if (unlikely(pkt->vlan_ex)) {
-               struct vlan_group *grp = pi->vlan_grp;
-
+               __vlan_hwaccel_put_tag(skb, ntohs(pkt->vlan));
                rxq->stats.vlan_ex++;
-               if (likely(grp))
-                       vlan_hwaccel_receive_skb(skb, grp, ntohs(pkt->vlan));
-               else
-                       dev_kfree_skb_any(skb);
-       } else
-               netif_receive_skb(skb);
-
+       }
+       netif_receive_skb(skb);
        return 0;
 }
 
index a117f2a0252e8c884f6d890f912556924635cae9..4686c3983fc3044f0e0af47cf75dee71b6dadb02 100644 (file)
@@ -521,7 +521,7 @@ void e1000_down(struct e1000_adapter *adapter)
        e1000_clean_all_rx_rings(adapter);
 }
 
-void e1000_reinit_safe(struct e1000_adapter *adapter)
+static void e1000_reinit_safe(struct e1000_adapter *adapter)
 {
        while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
                msleep(1);
index d7a975ee2add393010e9db6ad38fbd1c770603a4..d85edf3119c2625d999b22a41b6159ba9ebf7a24 100644 (file)
@@ -1623,12 +1623,12 @@ err_out:
        return rc;
 }
 
-#ifdef CONFIG_PM
 static void
 jme_set_100m_half(struct jme_adapter *jme)
 {
        u32 bmcr, tmp;
 
+       jme_phy_on(jme);
        bmcr = jme_mdio_read(jme->dev, jme->mii_if.phy_id, MII_BMCR);
        tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 |
                       BMCR_SPEED1000 | BMCR_FULLDPLX);
@@ -1656,7 +1656,6 @@ jme_wait_link(struct jme_adapter *jme)
                phylink = jme_linkstat_from_phy(jme);
        }
 }
-#endif
 
 static inline void
 jme_phy_off(struct jme_adapter *jme)
@@ -1664,6 +1663,21 @@ jme_phy_off(struct jme_adapter *jme)
        jme_mdio_write(jme->dev, jme->mii_if.phy_id, MII_BMCR, BMCR_PDOWN);
 }
 
+static void
+jme_powersave_phy(struct jme_adapter *jme)
+{
+       if (jme->reg_pmcs) {
+               jme_set_100m_half(jme);
+
+               if (jme->reg_pmcs & (PMCS_LFEN | PMCS_LREN))
+                       jme_wait_link(jme);
+
+               jwrite32(jme, JME_PMCS, jme->reg_pmcs);
+       } else {
+               jme_phy_off(jme);
+       }
+}
+
 static int
 jme_close(struct net_device *netdev)
 {
@@ -2991,6 +3005,16 @@ jme_remove_one(struct pci_dev *pdev)
 
 }
 
+static void
+jme_shutdown(struct pci_dev *pdev)
+{
+       struct net_device *netdev = pci_get_drvdata(pdev);
+       struct jme_adapter *jme = netdev_priv(netdev);
+
+       jme_powersave_phy(jme);
+       pci_pme_active(pdev, true);
+}
+
 #ifdef CONFIG_PM
 static int
 jme_suspend(struct pci_dev *pdev, pm_message_t state)
@@ -3028,19 +3052,9 @@ jme_suspend(struct pci_dev *pdev, pm_message_t state)
        tasklet_hi_enable(&jme->rxempty_task);
 
        pci_save_state(pdev);
-       if (jme->reg_pmcs) {
-               jme_set_100m_half(jme);
-
-               if (jme->reg_pmcs & (PMCS_LFEN | PMCS_LREN))
-                       jme_wait_link(jme);
-
-               jwrite32(jme, JME_PMCS, jme->reg_pmcs);
-
-               pci_enable_wake(pdev, PCI_D3cold, true);
-       } else {
-               jme_phy_off(jme);
-       }
-       pci_set_power_state(pdev, PCI_D3cold);
+       jme_powersave_phy(jme);
+       pci_enable_wake(jme->pdev, PCI_D3hot, true);
+       pci_set_power_state(pdev, PCI_D3hot);
 
        return 0;
 }
@@ -3087,6 +3101,7 @@ static struct pci_driver jme_driver = {
        .suspend        = jme_suspend,
        .resume         = jme_resume,
 #endif /* CONFIG_PM */
+       .shutdown       = jme_shutdown,
 };
 
 static int __init
index 4297f6e8c4bc0ab571dd571d9a6f08d5493c6e76..f69e73e2191e9e4a54f3f617e14d8ac6c33734ef 100644 (file)
@@ -515,14 +515,15 @@ static int macb_poll(struct napi_struct *napi, int budget)
                (unsigned long)status, budget);
 
        work_done = macb_rx(bp, budget);
-       if (work_done < budget)
+       if (work_done < budget) {
                napi_complete(napi);
 
-       /*
-        * We've done what we can to clean the buffers. Make sure we
-        * get notified when new packets arrive.
-        */
-       macb_writel(bp, IER, MACB_RX_INT_FLAGS);
+               /*
+                * We've done what we can to clean the buffers. Make sure we
+                * get notified when new packets arrive.
+                */
+               macb_writel(bp, IER, MACB_RX_INT_FLAGS);
+       }
 
        /* TODO: Handle errors */
 
@@ -550,12 +551,16 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
                }
 
                if (status & MACB_RX_INT_FLAGS) {
+                       /*
+                        * There's no point taking any more interrupts
+                        * until we have processed the buffers. The
+                        * scheduling call may fail if the poll routine
+                        * is already scheduled, so disable interrupts
+                        * now.
+                        */
+                       macb_writel(bp, IDR, MACB_RX_INT_FLAGS);
+
                        if (napi_schedule_prep(&bp->napi)) {
-                               /*
-                                * There's no point taking any more interrupts
-                                * until we have processed the buffers
-                                */
-                               macb_writel(bp, IDR, MACB_RX_INT_FLAGS);
                                dev_dbg(&bp->pdev->dev,
                                        "scheduling RX softirq\n");
                                __napi_schedule(&bp->napi);
index b07e4dee80aada693e46e0a4cabca678f8500ad8..02393fdf44c17e57cbf0fd775a86a20fc8f75a5a 100644 (file)
@@ -210,38 +210,12 @@ static int mlx4_MAP_ICM(struct mlx4_dev *dev, struct mlx4_icm *icm, u64 virt)
        return mlx4_map_cmd(dev, MLX4_CMD_MAP_ICM, icm, virt);
 }
 
-int mlx4_UNMAP_ICM(struct mlx4_dev *dev, u64 virt, u32 page_count)
+static int mlx4_UNMAP_ICM(struct mlx4_dev *dev, u64 virt, u32 page_count)
 {
        return mlx4_cmd(dev, virt, page_count, 0, MLX4_CMD_UNMAP_ICM,
                        MLX4_CMD_TIME_CLASS_B);
 }
 
-int mlx4_MAP_ICM_page(struct mlx4_dev *dev, u64 dma_addr, u64 virt)
-{
-       struct mlx4_cmd_mailbox *mailbox;
-       __be64 *inbox;
-       int err;
-
-       mailbox = mlx4_alloc_cmd_mailbox(dev);
-       if (IS_ERR(mailbox))
-               return PTR_ERR(mailbox);
-       inbox = mailbox->buf;
-
-       inbox[0] = cpu_to_be64(virt);
-       inbox[1] = cpu_to_be64(dma_addr);
-
-       err = mlx4_cmd(dev, mailbox->dma, 1, 0, MLX4_CMD_MAP_ICM,
-                      MLX4_CMD_TIME_CLASS_B);
-
-       mlx4_free_cmd_mailbox(dev, mailbox);
-
-       if (!err)
-               mlx4_dbg(dev, "Mapped page at %llx to %llx for ICM.\n",
-                         (unsigned long long) dma_addr, (unsigned long long) virt);
-
-       return err;
-}
-
 int mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm)
 {
        return mlx4_map_cmd(dev, MLX4_CMD_MAP_ICM_AUX, icm, -1);
index ab56a2f89b651eb3c33cba5da21e1686a21bb98e..b10c07a1dc1a09d4508d8b376f5f2622aa0c5d18 100644 (file)
@@ -128,8 +128,6 @@ static inline unsigned long mlx4_icm_size(struct mlx4_icm_iter *iter)
        return sg_dma_len(&iter->chunk->mem[iter->page_idx]);
 }
 
-int mlx4_UNMAP_ICM(struct mlx4_dev *dev, u64 virt, u32 page_count);
-int mlx4_MAP_ICM_page(struct mlx4_dev *dev, u64 dma_addr, u64 virt);
 int mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm);
 int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev);
 
index 606aa58afdead9458de5f3de2f19594074936798..8674ad5764c4a7660a9b98ab4f2a11a7e9acb684 100644 (file)
@@ -111,6 +111,12 @@ int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *index)
                        goto out;
                }
        }
+
+       if (free < 0) {
+               err = -ENOMEM;
+               goto out;
+       }
+
        mlx4_dbg(dev, "Free MAC index is %d\n", free);
 
        if (table->total == table->max) {
@@ -205,6 +211,11 @@ int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index)
                }
        }
 
+       if (free < 0) {
+               err = -ENOMEM;
+               goto out;
+       }
+
        if (table->total == table->max) {
                /* No free vlan entries */
                err = -ENOSPC;
index 1bb16cb794331ba975eddcc5327f1fc13ef495c9..7670aac0e93f465c5505a6bb799658299724c3e4 100644 (file)
@@ -65,7 +65,7 @@ EXPORT_SYMBOL(phy_print_status);
  *
  * Returns 0 on success on < 0 on error.
  */
-int phy_clear_interrupt(struct phy_device *phydev)
+static int phy_clear_interrupt(struct phy_device *phydev)
 {
        int err = 0;
 
@@ -82,7 +82,7 @@ int phy_clear_interrupt(struct phy_device *phydev)
  *
  * Returns 0 on success on < 0 on error.
  */
-int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
+static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
 {
        int err = 0;
 
@@ -208,7 +208,7 @@ static inline int phy_find_valid(int idx, u32 features)
  *   duplexes.  Drop down by one in this order:  1000/FULL,
  *   1000/HALF, 100/FULL, 100/HALF, 10/FULL, 10/HALF.
  */
-void phy_sanitize_settings(struct phy_device *phydev)
+static void phy_sanitize_settings(struct phy_device *phydev)
 {
        u32 features = phydev->supported;
        int idx;
@@ -223,7 +223,6 @@ void phy_sanitize_settings(struct phy_device *phydev)
        phydev->speed = settings[idx].speed;
        phydev->duplex = settings[idx].duplex;
 }
-EXPORT_SYMBOL(phy_sanitize_settings);
 
 /**
  * phy_ethtool_sset - generic ethtool sset function, handles all the details
@@ -532,7 +531,7 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
  * phy_enable_interrupts - Enable the interrupts from the PHY side
  * @phydev: target phy_device struct
  */
-int phy_enable_interrupts(struct phy_device *phydev)
+static int phy_enable_interrupts(struct phy_device *phydev)
 {
        int err;
 
@@ -545,13 +544,12 @@ int phy_enable_interrupts(struct phy_device *phydev)
 
        return err;
 }
-EXPORT_SYMBOL(phy_enable_interrupts);
 
 /**
  * phy_disable_interrupts - Disable the PHY interrupts from the PHY side
  * @phydev: target phy_device struct
  */
-int phy_disable_interrupts(struct phy_device *phydev)
+static int phy_disable_interrupts(struct phy_device *phydev)
 {
        int err;
 
@@ -574,7 +572,6 @@ phy_err:
 
        return err;
 }
-EXPORT_SYMBOL(phy_disable_interrupts);
 
 /**
  * phy_start_interrupts - request and enable interrupts for a PHY device
index 16ddc77313cb08348b3cdbdb7016bd5c56fb9304..993c52c82aeb632e49745ddc462303795bfe44bd 100644 (file)
@@ -57,6 +57,9 @@ extern void mdio_bus_exit(void);
 static LIST_HEAD(phy_fixup_list);
 static DEFINE_MUTEX(phy_fixup_lock);
 
+static int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
+                            u32 flags, phy_interface_t interface);
+
 /*
  * Creates a new phy_fixup and adds it to the list
  * @bus_id: A string which matches phydev->dev.bus_id (or PHY_ANY_ID)
@@ -146,7 +149,8 @@ int phy_scan_fixups(struct phy_device *phydev)
 }
 EXPORT_SYMBOL(phy_scan_fixups);
 
-struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
+static struct phy_device* phy_device_create(struct mii_bus *bus,
+                                           int addr, int phy_id)
 {
        struct phy_device *dev;
 
@@ -193,7 +197,6 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
 
        return dev;
 }
-EXPORT_SYMBOL(phy_device_create);
 
 /**
  * get_phy_id - reads the specified addr for its ID.
@@ -316,7 +319,7 @@ EXPORT_SYMBOL(phy_find_first);
  *   If you want to monitor your own link state, don't call
  *   this function.
  */
-void phy_prepare_link(struct phy_device *phydev,
+static void phy_prepare_link(struct phy_device *phydev,
                void (*handler)(struct net_device *))
 {
        phydev->adjust_link = handler;
@@ -435,8 +438,8 @@ int phy_init_hw(struct phy_device *phydev)
  *     the attaching device, and given a callback for link status
  *     change.  The phy_device is returned to the attaching driver.
  */
-int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
-                     u32 flags, phy_interface_t interface)
+static int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
+                            u32 flags, phy_interface_t interface)
 {
        struct device *d = &phydev->dev;
 
@@ -473,7 +476,6 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
         * (dev_flags and interface) */
        return phy_init_hw(phydev);
 }
-EXPORT_SYMBOL(phy_attach_direct);
 
 /**
  * phy_attach - attach a network device to a particular PHY device
@@ -540,7 +542,7 @@ EXPORT_SYMBOL(phy_detach);
  *   what is supported.  Returns < 0 on error, 0 if the PHY's advertisement
  *   hasn't changed, and > 0 if it has changed.
  */
-int genphy_config_advert(struct phy_device *phydev)
+static int genphy_config_advert(struct phy_device *phydev)
 {
        u32 advertise;
        int oldadv, adv;
@@ -605,7 +607,6 @@ int genphy_config_advert(struct phy_device *phydev)
 
        return changed;
 }
-EXPORT_SYMBOL(genphy_config_advert);
 
 /**
  * genphy_setup_forced - configures/forces speed/duplex from @phydev
@@ -615,7 +616,7 @@ EXPORT_SYMBOL(genphy_config_advert);
  *   to the values in phydev. Assumes that the values are valid.
  *   Please see phy_sanitize_settings().
  */
-int genphy_setup_forced(struct phy_device *phydev)
+static int genphy_setup_forced(struct phy_device *phydev)
 {
        int err;
        int ctl = 0;
index a478786840a65e8f35a5a825263926fd0f7078d2..22821398fc63765054eff056ab2529beedfb30fc 100644 (file)
@@ -2226,7 +2226,6 @@ int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf,
 int ql_core_dump(struct ql_adapter *qdev,
                struct ql_mpi_coredump *mpi_coredump);
 int ql_mb_about_fw(struct ql_adapter *qdev);
-int ql_wol(struct ql_adapter *qdev);
 int ql_mb_wol_set_magic(struct ql_adapter *qdev, u32 enable_wol);
 int ql_mb_wol_mode(struct ql_adapter *qdev, u32 wol);
 int ql_mb_set_led_cfg(struct ql_adapter *qdev, u32 led_config);
@@ -2243,16 +2242,13 @@ netdev_tx_t ql_lb_send(struct sk_buff *skb, struct net_device *ndev);
 void ql_check_lb_frame(struct ql_adapter *, struct sk_buff *);
 int ql_own_firmware(struct ql_adapter *qdev);
 int ql_clean_lb_rx_ring(struct rx_ring *rx_ring, int budget);
-void qlge_set_multicast_list(struct net_device *ndev);
 
-#if 1
-#define QL_ALL_DUMP
-#define QL_REG_DUMP
-#define QL_DEV_DUMP
-#define QL_CB_DUMP
+/* #define QL_ALL_DUMP */
+/* #define QL_REG_DUMP */
+/* #define QL_DEV_DUMP */
+/* #define QL_CB_DUMP */
 /* #define QL_IB_DUMP */
 /* #define QL_OB_DUMP */
-#endif
 
 #ifdef QL_REG_DUMP
 extern void ql_dump_xgmac_control_regs(struct ql_adapter *qdev);
index ba0053d8515e24096854ee7cb7a07e99da32617b..e6210563abd44560ae67958de027d4da98bcbbcf 100644 (file)
@@ -94,6 +94,9 @@ static DEFINE_PCI_DEVICE_TABLE(qlge_pci_tbl) = {
 
 MODULE_DEVICE_TABLE(pci, qlge_pci_tbl);
 
+static int ql_wol(struct ql_adapter *qdev);
+static void qlge_set_multicast_list(struct net_device *ndev);
+
 /* This hardware semaphore causes exclusive access to
  * resources shared between the NIC driver, MPI firmware,
  * FCOE firmware and the FC driver.
@@ -3842,7 +3845,7 @@ static void ql_display_dev_info(struct net_device *ndev)
                   "MAC address %pM\n", ndev->dev_addr);
 }
 
-int ql_wol(struct ql_adapter *qdev)
+static int ql_wol(struct ql_adapter *qdev)
 {
        int status = 0;
        u32 wol = MB_WOL_DISABLE;
@@ -4242,7 +4245,7 @@ static struct net_device_stats *qlge_get_stats(struct net_device
        return &ndev->stats;
 }
 
-void qlge_set_multicast_list(struct net_device *ndev)
+static void qlge_set_multicast_list(struct net_device *ndev)
 {
        struct ql_adapter *qdev = (struct ql_adapter *)netdev_priv(ndev);
        struct netdev_hw_addr *ha;
index f84e8570c7cb79d4c161e90ccee1d420b55d256c..0e7c7c7ee1647006baf561ffd90308290fbd2399 100644 (file)
@@ -87,7 +87,7 @@ exit:
        return status;
 }
 
-int ql_soft_reset_mpi_risc(struct ql_adapter *qdev)
+static int ql_soft_reset_mpi_risc(struct ql_adapter *qdev)
 {
        int status;
        status = ql_write_mpi_reg(qdev, 0x00001010, 1);
@@ -681,7 +681,7 @@ int ql_mb_get_fw_state(struct ql_adapter *qdev)
 /* Send and ACK mailbox command to the firmware to
  * let it continue with the change.
  */
-int ql_mb_idc_ack(struct ql_adapter *qdev)
+static int ql_mb_idc_ack(struct ql_adapter *qdev)
 {
        struct mbox_params mbc;
        struct mbox_params *mbcp = &mbc;
@@ -744,7 +744,7 @@ int ql_mb_set_port_cfg(struct ql_adapter *qdev)
        return status;
 }
 
-int ql_mb_dump_ram(struct ql_adapter *qdev, u64 req_dma, u32 addr,
+static int ql_mb_dump_ram(struct ql_adapter *qdev, u64 req_dma, u32 addr,
        u32 size)
 {
        int status = 0;
index 9265315baa0b29bdc2c7a9e20db20462dcf52ae5..3a0cc63428eec6d8222dee806b0594af9aa9f95c 100644 (file)
@@ -531,7 +531,7 @@ static int sgiseeq_open(struct net_device *dev)
 
        if (request_irq(irq, sgiseeq_interrupt, 0, sgiseeqstr, dev)) {
                printk(KERN_ERR "Seeq8003: Can't get irq %d\n", dev->irq);
-               err = -EAGAIN;
+               return -EAGAIN;
        }
 
        err = init_seeq(dev, sp, sregs);
index ac279fad9d450d28489a908a39884678676c3f73..ab9e3b785b5b1bf86b593160f97c213d191f2e0a 100644 (file)
@@ -688,18 +688,8 @@ slhc_toss(struct slcompress *comp)
        return 0;
 }
 
-
-/* VJ header compression */
-EXPORT_SYMBOL(slhc_init);
-EXPORT_SYMBOL(slhc_free);
-EXPORT_SYMBOL(slhc_remember);
-EXPORT_SYMBOL(slhc_compress);
-EXPORT_SYMBOL(slhc_uncompress);
-EXPORT_SYMBOL(slhc_toss);
-
 #else /* CONFIG_INET */
 
-
 int
 slhc_toss(struct slcompress *comp)
 {
@@ -738,6 +728,10 @@ slhc_init(int rslots, int tslots)
   printk(KERN_DEBUG "Called IP function on non IP-system: slhc_init");
   return NULL;
 }
+
+#endif /* CONFIG_INET */
+
+/* VJ header compression */
 EXPORT_SYMBOL(slhc_init);
 EXPORT_SYMBOL(slhc_free);
 EXPORT_SYMBOL(slhc_remember);
@@ -745,5 +739,4 @@ EXPORT_SYMBOL(slhc_compress);
 EXPORT_SYMBOL(slhc_uncompress);
 EXPORT_SYMBOL(slhc_toss);
 
-#endif /* CONFIG_INET */
 MODULE_LICENSE("Dual BSD/GPL");
index 663b8860a5317a4f37a41813e79fda4bd8159792..793020347e543524708512d5ad0e0681ba0ad1fd 100644 (file)
@@ -1220,7 +1220,7 @@ void tms380tr_wait(unsigned long time)
                tmp = schedule_timeout_interruptible(tmp);
        } while(time_after(tmp, jiffies));
 #else
-       udelay(time);
+       mdelay(time / 1000);
 #endif
 }
 
index 1cc67138adbf4a248294a029295df268bfbbc710..b550da008a03fdfac1521555b42211fb195d0085 100644 (file)
        3XP Processor. It has been tested on x86 and sparc64.
 
        KNOWN ISSUES:
-       *) The current firmware always strips the VLAN tag off, even if
-               we tell it not to. You should filter VLANs at the switch
-               as a workaround (good practice in any event) until we can
-               get this fixed.
        *) Cannot DMA Rx packets to a 2 byte aligned address. Also firmware
                issue. Hopefully 3Com will fix it.
        *) Waiting for a command response takes 8ms due to non-preemptable
@@ -280,8 +276,6 @@ struct typhoon {
        struct pci_dev *        pdev;
        struct net_device *     dev;
        struct napi_struct      napi;
-       spinlock_t              state_lock;
-       struct vlan_group *     vlgrp;
        struct basic_ring       rxHiRing;
        struct basic_ring       rxBuffRing;
        struct rxbuff_ent       rxbuffers[RXENT_ENTRIES];
@@ -695,44 +689,6 @@ out:
        return err;
 }
 
-static void
-typhoon_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
-{
-       struct typhoon *tp = netdev_priv(dev);
-       struct cmd_desc xp_cmd;
-       int err;
-
-       spin_lock_bh(&tp->state_lock);
-       if(!tp->vlgrp != !grp) {
-               /* We've either been turned on for the first time, or we've
-                * been turned off. Update the 3XP.
-                */
-               if(grp)
-                       tp->offload |= TYPHOON_OFFLOAD_VLAN;
-               else
-                       tp->offload &= ~TYPHOON_OFFLOAD_VLAN;
-
-               /* If the interface is up, the runtime is running -- and we
-                * must be up for the vlan core to call us.
-                *
-                * Do the command outside of the spin lock, as it is slow.
-                */
-               INIT_COMMAND_WITH_RESPONSE(&xp_cmd,
-                                       TYPHOON_CMD_SET_OFFLOAD_TASKS);
-               xp_cmd.parm2 = tp->offload;
-               xp_cmd.parm3 = tp->offload;
-               spin_unlock_bh(&tp->state_lock);
-               err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL);
-               if(err < 0)
-                       netdev_err(tp->dev, "vlan offload error %d\n", -err);
-               spin_lock_bh(&tp->state_lock);
-       }
-
-       /* now make the change visible */
-       tp->vlgrp = grp;
-       spin_unlock_bh(&tp->state_lock);
-}
-
 static inline void
 typhoon_tso_fill(struct sk_buff *skb, struct transmit_ring *txRing,
                        u32 ring_dma)
@@ -818,7 +774,7 @@ typhoon_start_tx(struct sk_buff *skb, struct net_device *dev)
                first_txd->processFlags |=
                    TYPHOON_TX_PF_INSERT_VLAN | TYPHOON_TX_PF_VLAN_PRIORITY;
                first_txd->processFlags |=
-                   cpu_to_le32(ntohs(vlan_tx_tag_get(skb)) <<
+                   cpu_to_le32(htons(vlan_tx_tag_get(skb)) <<
                                TYPHOON_TX_PF_VLAN_TAG_SHIFT);
        }
 
@@ -936,7 +892,7 @@ typhoon_set_rx_mode(struct net_device *dev)
                filter |= TYPHOON_RX_FILTER_MCAST_HASH;
        }
 
-       INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_RX_FILTER);
+       INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_RX_FILTER);
        xp_cmd.parm1 = filter;
        typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL);
 }
@@ -1198,6 +1154,20 @@ typhoon_get_rx_csum(struct net_device *dev)
        return 1;
 }
 
+static int
+typhoon_set_flags(struct net_device *dev, u32 data)
+{
+       /* There's no way to turn off the RX VLAN offloading and stripping
+        * on the current 3XP firmware -- it does not respect the offload
+        * settings -- so we only allow the user to toggle the TX processing.
+        */
+       if (!(data & ETH_FLAG_RXVLAN))
+               return -EINVAL;
+
+       return ethtool_op_set_flags(dev, data,
+                                   ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN);
+}
+
 static void
 typhoon_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
 {
@@ -1224,6 +1194,8 @@ static const struct ethtool_ops typhoon_ethtool_ops = {
        .set_sg                 = ethtool_op_set_sg,
        .set_tso                = ethtool_op_set_tso,
        .get_ringparam          = typhoon_get_ringparam,
+       .set_flags              = typhoon_set_flags,
+       .get_flags              = ethtool_op_get_flags,
 };
 
 static int
@@ -1309,9 +1281,9 @@ typhoon_init_interface(struct typhoon *tp)
 
        tp->offload = TYPHOON_OFFLOAD_IP_CHKSUM | TYPHOON_OFFLOAD_TCP_CHKSUM;
        tp->offload |= TYPHOON_OFFLOAD_UDP_CHKSUM | TSO_OFFLOAD_ON;
+       tp->offload |= TYPHOON_OFFLOAD_VLAN;
 
        spin_lock_init(&tp->command_lock);
-       spin_lock_init(&tp->state_lock);
 
        /* Force the writes to the shared memory area out before continuing. */
        wmb();
@@ -1762,13 +1734,10 @@ typhoon_rx(struct typhoon *tp, struct basic_ring *rxRing, volatile __le32 * read
                } else
                        skb_checksum_none_assert(new_skb);
 
-               spin_lock(&tp->state_lock);
-               if(tp->vlgrp != NULL && rx->rxStatus & TYPHOON_RX_VLAN)
-                       vlan_hwaccel_receive_skb(new_skb, tp->vlgrp,
-                                                ntohl(rx->vlanTag) & 0xffff);
-               else
-                       netif_receive_skb(new_skb);
-               spin_unlock(&tp->state_lock);
+               if (rx->rxStatus & TYPHOON_RX_VLAN)
+                       __vlan_hwaccel_put_tag(new_skb,
+                                              ntohl(rx->vlanTag) & 0xffff);
+               netif_receive_skb(new_skb);
 
                received++;
                budget--;
@@ -1989,11 +1958,9 @@ typhoon_start_runtime(struct typhoon *tp)
                goto error_out;
 
        INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_OFFLOAD_TASKS);
-       spin_lock_bh(&tp->state_lock);
        xp_cmd.parm2 = tp->offload;
        xp_cmd.parm3 = tp->offload;
        err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL);
-       spin_unlock_bh(&tp->state_lock);
        if(err < 0)
                goto error_out;
 
@@ -2231,13 +2198,9 @@ typhoon_suspend(struct pci_dev *pdev, pm_message_t state)
        if(!netif_running(dev))
                return 0;
 
-       spin_lock_bh(&tp->state_lock);
-       if(tp->vlgrp && tp->wol_events & TYPHOON_WAKE_MAGIC_PKT) {
-               spin_unlock_bh(&tp->state_lock);
-               netdev_err(dev, "cannot do WAKE_MAGIC with VLANS\n");
-               return -EBUSY;
-       }
-       spin_unlock_bh(&tp->state_lock);
+       /* TYPHOON_OFFLOAD_VLAN is always on now, so this doesn't work */
+       if(tp->wol_events & TYPHOON_WAKE_MAGIC_PKT)
+               netdev_warn(dev, "cannot do WAKE_MAGIC with VLAN offloading\n");
 
        netif_device_detach(dev);
 
@@ -2338,7 +2301,6 @@ static const struct net_device_ops typhoon_netdev_ops = {
        .ndo_validate_addr      = eth_validate_addr,
        .ndo_set_mac_address    = typhoon_set_mac_address,
        .ndo_change_mtu         = eth_change_mtu,
-       .ndo_vlan_rx_register   = typhoon_vlan_rx_register,
 };
 
 static int __devinit
index 37108fb226d38e5a08a99e3dbaf2134aff6eedd6..969c751ee404fae24e73614703fe44e6141d74f9 100644 (file)
@@ -88,9 +88,9 @@ struct UPT1_RSSConf {
 
 /* features */
 enum {
-       UPT1_F_RXCSUM           = 0x0001,   /* rx csum verification */
-       UPT1_F_RSS              = 0x0002,
-       UPT1_F_RXVLAN           = 0x0004,   /* VLAN tag stripping */
-       UPT1_F_LRO              = 0x0008,
+       UPT1_F_RXCSUM           = cpu_to_le64(0x0001),   /* rx csum verification */
+       UPT1_F_RSS              = cpu_to_le64(0x0002),
+       UPT1_F_RXVLAN           = cpu_to_le64(0x0004),   /* VLAN tag stripping */
+       UPT1_F_LRO              = cpu_to_le64(0x0008),
 };
 #endif
index ca7727b940adfd62c58bb01c32737a9c88dedcc0..4d84912c99bae05f19eec5abf04632e077c1cc4f 100644 (file)
@@ -523,9 +523,9 @@ struct Vmxnet3_RxFilterConf {
 #define VMXNET3_PM_MAX_PATTERN_SIZE   128
 #define VMXNET3_PM_MAX_MASK_SIZE      (VMXNET3_PM_MAX_PATTERN_SIZE / 8)
 
-#define VMXNET3_PM_WAKEUP_MAGIC       0x01  /* wake up on magic pkts */
-#define VMXNET3_PM_WAKEUP_FILTER      0x02  /* wake up on pkts matching
-                                            * filters */
+#define VMXNET3_PM_WAKEUP_MAGIC       cpu_to_le16(0x01)  /* wake up on magic pkts */
+#define VMXNET3_PM_WAKEUP_FILTER      cpu_to_le16(0x02)  /* wake up on pkts matching
+                                                         * filters */
 
 
 struct Vmxnet3_PM_PktFilter {
index 3f60e0e3097bdee3237ebdae7ef2d66844ce1669..e3658e10db390dd2ef74d62bd9c34004abe2d4dd 100644 (file)
@@ -1563,8 +1563,7 @@ vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
                        adapter->vlan_grp = grp;
 
                        /* update FEATURES to device */
-                       set_flag_le64(&devRead->misc.uptFeatures,
-                                     UPT1_F_RXVLAN);
+                       devRead->misc.uptFeatures |= UPT1_F_RXVLAN;
                        VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
                                               VMXNET3_CMD_UPDATE_FEATURE);
                        /*
@@ -1587,7 +1586,7 @@ vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
                struct Vmxnet3_DSDevRead *devRead = &shared->devRead;
                adapter->vlan_grp = NULL;
 
-               if (le64_to_cpu(devRead->misc.uptFeatures) & UPT1_F_RXVLAN) {
+               if (devRead->misc.uptFeatures & UPT1_F_RXVLAN) {
                        int i;
 
                        for (i = 0; i < VMXNET3_VFT_SIZE; i++) {
@@ -1600,8 +1599,7 @@ vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
                                               VMXNET3_CMD_UPDATE_VLAN_FILTERS);
 
                        /* update FEATURES to device */
-                       reset_flag_le64(&devRead->misc.uptFeatures,
-                                       UPT1_F_RXVLAN);
+                       devRead->misc.uptFeatures &= ~UPT1_F_RXVLAN;
                        VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
                                               VMXNET3_CMD_UPDATE_FEATURE);
                }
@@ -1762,15 +1760,15 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
 
        /* set up feature flags */
        if (adapter->rxcsum)
-               set_flag_le64(&devRead->misc.uptFeatures, UPT1_F_RXCSUM);
+               devRead->misc.uptFeatures |= UPT1_F_RXCSUM;
 
        if (adapter->lro) {
-               set_flag_le64(&devRead->misc.uptFeatures, UPT1_F_LRO);
+               devRead->misc.uptFeatures |= UPT1_F_LRO;
                devRead->misc.maxNumRxSG = cpu_to_le16(1 + MAX_SKB_FRAGS);
        }
        if ((adapter->netdev->features & NETIF_F_HW_VLAN_RX) &&
            adapter->vlan_grp) {
-               set_flag_le64(&devRead->misc.uptFeatures, UPT1_F_RXVLAN);
+               devRead->misc.uptFeatures |= UPT1_F_RXVLAN;
        }
 
        devRead->misc.mtu = cpu_to_le32(adapter->netdev->mtu);
@@ -2577,7 +2575,7 @@ vmxnet3_suspend(struct device *device)
                memcpy(pmConf->filters[i].pattern, netdev->dev_addr, ETH_ALEN);
                pmConf->filters[i].mask[0] = 0x3F; /* LSB ETH_ALEN bits */
 
-               set_flag_le16(&pmConf->wakeUpEvents, VMXNET3_PM_WAKEUP_FILTER);
+               pmConf->wakeUpEvents |= VMXNET3_PM_WAKEUP_FILTER;
                i++;
        }
 
@@ -2619,13 +2617,13 @@ vmxnet3_suspend(struct device *device)
                pmConf->filters[i].mask[5] = 0x03; /* IPv4 TIP */
                in_dev_put(in_dev);
 
-               set_flag_le16(&pmConf->wakeUpEvents, VMXNET3_PM_WAKEUP_FILTER);
+               pmConf->wakeUpEvents |= VMXNET3_PM_WAKEUP_FILTER;
                i++;
        }
 
 skip_arp:
        if (adapter->wol & WAKE_MAGIC)
-               set_flag_le16(&pmConf->wakeUpEvents, VMXNET3_PM_WAKEUP_MAGIC);
+               pmConf->wakeUpEvents |= VMXNET3_PM_WAKEUP_MAGIC;
 
        pmConf->numFilters = i;
 
@@ -2667,7 +2665,7 @@ vmxnet3_resume(struct device *device)
        adapter->shared->devRead.pmConfDesc.confVer = cpu_to_le32(1);
        adapter->shared->devRead.pmConfDesc.confLen = cpu_to_le32(sizeof(
                                                                  *pmConf));
-       adapter->shared->devRead.pmConfDesc.confPA = cpu_to_le32(virt_to_phys(
+       adapter->shared->devRead.pmConfDesc.confPA = cpu_to_le64(virt_to_phys(
                                                                 pmConf));
 
        netif_device_attach(netdev);
index 7e4b5a89165a5804dcb68dd78d225163ea71efd7..b79070bcc92efa592e9e8c1689d9e7061b8788c0 100644 (file)
@@ -50,13 +50,11 @@ vmxnet3_set_rx_csum(struct net_device *netdev, u32 val)
                adapter->rxcsum = val;
                if (netif_running(netdev)) {
                        if (val)
-                               set_flag_le64(
-                               &adapter->shared->devRead.misc.uptFeatures,
-                               UPT1_F_RXCSUM);
+                               adapter->shared->devRead.misc.uptFeatures |=
+                               UPT1_F_RXCSUM;
                        else
-                               reset_flag_le64(
-                               &adapter->shared->devRead.misc.uptFeatures,
-                               UPT1_F_RXCSUM);
+                               adapter->shared->devRead.misc.uptFeatures &=
+                               ~UPT1_F_RXCSUM;
 
                        VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
                                               VMXNET3_CMD_UPDATE_FEATURE);
@@ -292,10 +290,10 @@ vmxnet3_set_flags(struct net_device *netdev, u32 data)
                /* update harware LRO capability accordingly */
                if (lro_requested)
                        adapter->shared->devRead.misc.uptFeatures |=
-                                               cpu_to_le64(UPT1_F_LRO);
+                                                       UPT1_F_LRO;
                else
                        adapter->shared->devRead.misc.uptFeatures &=
-                                               cpu_to_le64(~UPT1_F_LRO);
+                                                       ~UPT1_F_LRO;
                VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
                                       VMXNET3_CMD_UPDATE_FEATURE);
        }
index c88ea5cbba0d064a85563f78780016a42badeb05..8a2f4712284cfcbf0f2851547e43a2ef5f0fd595 100644 (file)
@@ -301,8 +301,8 @@ struct vmxnet3_adapter {
        struct net_device              *netdev;
        struct pci_dev                 *pdev;
 
-       u8                              *hw_addr0; /* for BAR 0 */
-       u8                              *hw_addr1; /* for BAR 1 */
+       u8                      __iomem *hw_addr0; /* for BAR 0 */
+       u8                      __iomem *hw_addr1; /* for BAR 1 */
 
        /* feature control */
        bool                            rxcsum;
@@ -353,21 +353,6 @@ struct vmxnet3_adapter {
 #define VMXNET3_MAX_ETH_HDR_SIZE    22
 #define VMXNET3_MAX_SKB_BUF_SIZE    (3*1024)
 
-static inline void set_flag_le16(__le16 *data, u16 flag)
-{
-       *data = cpu_to_le16(le16_to_cpu(*data) | flag);
-}
-
-static inline void set_flag_le64(__le64 *data, u64 flag)
-{
-       *data = cpu_to_le64(le64_to_cpu(*data) | flag);
-}
-
-static inline void reset_flag_le64(__le64 *data, u64 flag)
-{
-       *data = cpu_to_le64(le64_to_cpu(*data) & ~flag);
-}
-
 int
 vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter);
 
index 0e6db5935609cf47efb6c1f2788e6bfeac496db8..906a3ca3676b94c3aa6d8442bd7e56b9d0fa3eca 100644 (file)
 #include "vxge-traffic.h"
 #include "vxge-config.h"
 
+static enum vxge_hw_status
+__vxge_hw_fifo_create(
+       struct __vxge_hw_vpath_handle *vpath_handle,
+       struct vxge_hw_fifo_attr *attr);
+
+static enum vxge_hw_status
+__vxge_hw_fifo_abort(
+       struct __vxge_hw_fifo *fifoh);
+
+static enum vxge_hw_status
+__vxge_hw_fifo_reset(
+       struct __vxge_hw_fifo *ringh);
+
+static enum vxge_hw_status
+__vxge_hw_fifo_delete(
+       struct __vxge_hw_vpath_handle *vpath_handle);
+
+static struct __vxge_hw_blockpool_entry *
+__vxge_hw_blockpool_block_allocate(struct __vxge_hw_device *hldev,
+                       u32 size);
+
+static void
+__vxge_hw_blockpool_block_free(struct __vxge_hw_device *hldev,
+                       struct __vxge_hw_blockpool_entry *entry);
+
+static void vxge_hw_blockpool_block_add(struct __vxge_hw_device *devh,
+                                       void *block_addr,
+                                       u32 length,
+                                       struct pci_dev *dma_h,
+                                       struct pci_dev *acc_handle);
+
+static enum vxge_hw_status
+__vxge_hw_blockpool_create(struct __vxge_hw_device *hldev,
+                       struct __vxge_hw_blockpool  *blockpool,
+                       u32 pool_size,
+                       u32 pool_max);
+
+static void
+__vxge_hw_blockpool_destroy(struct __vxge_hw_blockpool  *blockpool);
+
+static void *
+__vxge_hw_blockpool_malloc(struct __vxge_hw_device *hldev,
+                       u32 size,
+                       struct vxge_hw_mempool_dma *dma_object);
+
+static void
+__vxge_hw_blockpool_free(struct __vxge_hw_device *hldev,
+                       void *memblock,
+                       u32 size,
+                       struct vxge_hw_mempool_dma *dma_object);
+
+
+static struct __vxge_hw_channel*
+__vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph,
+                       enum __vxge_hw_channel_type type, u32 length,
+                       u32 per_dtr_space, void *userdata);
+
+static void
+__vxge_hw_channel_free(
+       struct __vxge_hw_channel *channel);
+
+static enum vxge_hw_status
+__vxge_hw_channel_initialize(
+       struct __vxge_hw_channel *channel);
+
+static enum vxge_hw_status
+__vxge_hw_channel_reset(
+       struct __vxge_hw_channel *channel);
+
+static enum vxge_hw_status __vxge_hw_ring_delete(struct __vxge_hw_vpath_handle *vp);
+
+static enum vxge_hw_status
+__vxge_hw_device_fifo_config_check(struct vxge_hw_fifo_config *fifo_config);
+
+static enum vxge_hw_status
+__vxge_hw_device_config_check(struct vxge_hw_device_config *new_config);
+
+static void
+__vxge_hw_device_id_get(struct __vxge_hw_device *hldev);
+
+static void
+__vxge_hw_device_host_info_get(struct __vxge_hw_device *hldev);
+
+static enum vxge_hw_status
+__vxge_hw_vpath_card_info_get(
+       u32 vp_id,
+       struct vxge_hw_vpath_reg __iomem *vpath_reg,
+       struct vxge_hw_device_hw_info *hw_info);
+
+static enum vxge_hw_status
+__vxge_hw_device_initialize(struct __vxge_hw_device *hldev);
+
+static void
+__vxge_hw_device_pci_e_init(struct __vxge_hw_device *hldev);
+
+static enum vxge_hw_status
+__vxge_hw_device_reg_addr_get(struct __vxge_hw_device *hldev);
+
+static enum vxge_hw_status
+__vxge_hw_device_register_poll(
+       void __iomem    *reg,
+       u64 mask, u32 max_millis);
+
+static inline enum vxge_hw_status
+__vxge_hw_pio_mem_write64(u64 val64, void __iomem *addr,
+                         u64 mask, u32 max_millis)
+{
+       __vxge_hw_pio_mem_write32_lower((u32)vxge_bVALn(val64, 32, 32), addr);
+       wmb();
+
+       __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(val64, 0, 32), addr);
+       wmb();
+
+       return  __vxge_hw_device_register_poll(addr, mask, max_millis);
+}
+
+static struct vxge_hw_mempool*
+__vxge_hw_mempool_create(struct __vxge_hw_device *devh, u32 memblock_size,
+                        u32 item_size, u32 private_size, u32 items_initial,
+                        u32 items_max, struct vxge_hw_mempool_cbs *mp_callback,
+                        void *userdata);
+static void __vxge_hw_mempool_destroy(struct vxge_hw_mempool *mempool);
+
+static enum vxge_hw_status
+__vxge_hw_vpath_stats_get(struct __vxge_hw_virtualpath *vpath,
+                         struct vxge_hw_vpath_stats_hw_info *hw_stats);
+
+static enum vxge_hw_status
+vxge_hw_vpath_stats_enable(struct __vxge_hw_vpath_handle *vpath_handle);
+
+static enum vxge_hw_status
+__vxge_hw_legacy_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg);
+
+static u64
+__vxge_hw_vpath_pci_func_mode_get(u32  vp_id,
+                                 struct vxge_hw_vpath_reg __iomem *vpath_reg);
+
+static u32
+__vxge_hw_vpath_func_id_get(u32 vp_id, struct vxge_hw_vpmgmt_reg __iomem *vpmgmt_reg);
+
+static enum vxge_hw_status
+__vxge_hw_vpath_addr_get(u32 vp_id, struct vxge_hw_vpath_reg __iomem *vpath_reg,
+                        u8 (macaddr)[ETH_ALEN], u8 (macaddr_mask)[ETH_ALEN]);
+
+static enum vxge_hw_status
+__vxge_hw_vpath_reset_check(struct __vxge_hw_virtualpath *vpath);
+
+
+static enum vxge_hw_status
+__vxge_hw_vpath_sw_reset(struct __vxge_hw_device *devh, u32 vp_id);
+
+static enum vxge_hw_status
+__vxge_hw_vpath_fw_ver_get(u32 vp_id, struct vxge_hw_vpath_reg __iomem *vpath_reg,
+                          struct vxge_hw_device_hw_info *hw_info);
+
+static enum vxge_hw_status
+__vxge_hw_vpath_mac_configure(struct __vxge_hw_device *devh, u32 vp_id);
+
+static void
+__vxge_hw_vp_terminate(struct __vxge_hw_device *devh, u32 vp_id);
+
+static enum vxge_hw_status
+__vxge_hw_vpath_stats_access(struct __vxge_hw_virtualpath *vpath,
+                            u32 operation, u32 offset, u64 *stat);
+
+static enum vxge_hw_status
+__vxge_hw_vpath_xmac_tx_stats_get(struct __vxge_hw_virtualpath *vpath,
+                                 struct vxge_hw_xmac_vpath_tx_stats *vpath_tx_stats);
+
+static enum vxge_hw_status
+__vxge_hw_vpath_xmac_rx_stats_get(struct __vxge_hw_virtualpath *vpath,
+                                 struct vxge_hw_xmac_vpath_rx_stats *vpath_rx_stats);
+
 /*
  * __vxge_hw_channel_allocate - Allocate memory for channel
  * This function allocates required memory for the channel and various arrays
@@ -190,7 +363,7 @@ __vxge_hw_device_pci_e_init(struct __vxge_hw_device *hldev)
  * Will poll certain register for specified amount of time.
  * Will poll until masked bit is not cleared.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_device_register_poll(void __iomem *reg, u64 mask, u32 max_millis)
 {
        u64 val64;
@@ -221,7 +394,7 @@ __vxge_hw_device_register_poll(void __iomem *reg, u64 mask, u32 max_millis)
  * in progress
  * This routine checks the vpath reset in progress register is turned zero
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_device_vpath_reset_in_prog_check(u64 __iomem *vpath_rst_in_prog)
 {
        enum vxge_hw_status status;
@@ -236,7 +409,7 @@ __vxge_hw_device_vpath_reset_in_prog_check(u64 __iomem *vpath_rst_in_prog)
  * This routine sets the swapper and reads the toc pointer and returns the
  * memory mapped address of the toc
  */
-struct vxge_hw_toc_reg __iomem *
+static struct vxge_hw_toc_reg __iomem *
 __vxge_hw_device_toc_get(void __iomem *bar0)
 {
        u64 val64;
@@ -779,7 +952,7 @@ exit:
  * vxge_hw_device_xmac_aggr_stats_get - Get the Statistics on aggregate port
  * Get the Statistics on aggregate port
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_hw_device_xmac_aggr_stats_get(struct __vxge_hw_device *hldev, u32 port,
                                   struct vxge_hw_xmac_aggr_stats *aggr_stats)
 {
@@ -814,7 +987,7 @@ exit:
  * vxge_hw_device_xmac_port_stats_get - Get the Statistics on a port
  * Get the Statistics on port
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_hw_device_xmac_port_stats_get(struct __vxge_hw_device *hldev, u32 port,
                                   struct vxge_hw_xmac_port_stats *port_stats)
 {
@@ -952,20 +1125,6 @@ u32 vxge_hw_device_trace_level_get(struct __vxge_hw_device *hldev)
        return 0;
 #endif
 }
-/*
- * vxge_hw_device_debug_mask_get - Get the debug mask
- * This routine returns the current debug mask set
- */
-u32 vxge_hw_device_debug_mask_get(struct __vxge_hw_device *hldev)
-{
-#if defined(VXGE_DEBUG_TRACE_MASK) || defined(VXGE_DEBUG_ERR_MASK)
-       if (hldev == NULL)
-               return 0;
-       return hldev->debug_module_mask;
-#else
-       return 0;
-#endif
-}
 
 /*
  * vxge_hw_getpause_data -Pause frame frame generation and reception.
@@ -1090,7 +1249,7 @@ __vxge_hw_ring_block_next_pointer_set(u8 *block, dma_addr_t dma_next)
  *             first block
  * Returns the dma address of the first RxD block
  */
-u64 __vxge_hw_ring_first_block_address_get(struct __vxge_hw_ring *ring)
+static u64 __vxge_hw_ring_first_block_address_get(struct __vxge_hw_ring *ring)
 {
        struct vxge_hw_mempool_dma *dma_object;
 
@@ -1252,7 +1411,7 @@ exit:
  * This function creates Ring and initializes it.
  *
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_ring_create(struct __vxge_hw_vpath_handle *vp,
                      struct vxge_hw_ring_attr *attr)
 {
@@ -1363,7 +1522,7 @@ exit:
  * __vxge_hw_ring_abort - Returns the RxD
  * This function terminates the RxDs of ring
  */
-enum vxge_hw_status __vxge_hw_ring_abort(struct __vxge_hw_ring *ring)
+static enum vxge_hw_status __vxge_hw_ring_abort(struct __vxge_hw_ring *ring)
 {
        void *rxdh;
        struct __vxge_hw_channel *channel;
@@ -1392,7 +1551,7 @@ enum vxge_hw_status __vxge_hw_ring_abort(struct __vxge_hw_ring *ring)
  * __vxge_hw_ring_reset - Resets the ring
  * This function resets the ring during vpath reset operation
  */
-enum vxge_hw_status __vxge_hw_ring_reset(struct __vxge_hw_ring *ring)
+static enum vxge_hw_status __vxge_hw_ring_reset(struct __vxge_hw_ring *ring)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
        struct __vxge_hw_channel *channel;
@@ -1419,7 +1578,7 @@ exit:
  * __vxge_hw_ring_delete - Removes the ring
  * This function freeup the memory pool and removes the ring
  */
-enum vxge_hw_status __vxge_hw_ring_delete(struct __vxge_hw_vpath_handle *vp)
+static enum vxge_hw_status __vxge_hw_ring_delete(struct __vxge_hw_vpath_handle *vp)
 {
        struct __vxge_hw_ring *ring = vp->vpath->ringh;
 
@@ -1438,7 +1597,7 @@ enum vxge_hw_status __vxge_hw_ring_delete(struct __vxge_hw_vpath_handle *vp)
  * __vxge_hw_mempool_grow
  * Will resize mempool up to %num_allocate value.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_mempool_grow(struct vxge_hw_mempool *mempool, u32 num_allocate,
                       u32 *num_allocated)
 {
@@ -1527,7 +1686,7 @@ exit:
  * with size enough to hold %items_initial number of items. Memory is
  * DMA-able but client must map/unmap before interoperating with the device.
  */
-struct vxge_hw_mempool*
+static struct vxge_hw_mempool*
 __vxge_hw_mempool_create(
        struct __vxge_hw_device *devh,
        u32 memblock_size,
@@ -1644,7 +1803,7 @@ exit:
 /*
  * vxge_hw_mempool_destroy
  */
-void __vxge_hw_mempool_destroy(struct vxge_hw_mempool *mempool)
+static void __vxge_hw_mempool_destroy(struct vxge_hw_mempool *mempool)
 {
        u32 i, j;
        struct __vxge_hw_device *devh = mempool->devh;
@@ -1700,7 +1859,7 @@ __vxge_hw_device_fifo_config_check(struct vxge_hw_fifo_config *fifo_config)
  * __vxge_hw_device_vpath_config_check - Check vpath configuration.
  * Check the vpath configuration
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_device_vpath_config_check(struct vxge_hw_vp_config *vp_config)
 {
        enum vxge_hw_status status;
@@ -1922,7 +2081,7 @@ vxge_hw_device_config_default_get(struct vxge_hw_device_config *device_config)
  * _hw_legacy_swapper_set - Set the swapper bits for the legacy secion.
  * Set the swapper bits appropriately for the lagacy section.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_legacy_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg)
 {
        u64 val64;
@@ -1977,7 +2136,7 @@ __vxge_hw_legacy_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg)
  * __vxge_hw_vpath_swapper_set - Set the swapper bits for the vpath.
  * Set the swapper bits appropriately for the vpath.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_swapper_set(struct vxge_hw_vpath_reg __iomem *vpath_reg)
 {
 #ifndef __BIG_ENDIAN
@@ -1996,7 +2155,7 @@ __vxge_hw_vpath_swapper_set(struct vxge_hw_vpath_reg __iomem *vpath_reg)
  * __vxge_hw_kdfc_swapper_set - Set the swapper bits for the kdfc.
  * Set the swapper bits appropriately for the vpath.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_kdfc_swapper_set(
        struct vxge_hw_legacy_reg __iomem *legacy_reg,
        struct vxge_hw_vpath_reg __iomem *vpath_reg)
@@ -2020,28 +2179,6 @@ __vxge_hw_kdfc_swapper_set(
        return VXGE_HW_OK;
 }
 
-/*
- * vxge_hw_mgmt_device_config - Retrieve device configuration.
- * Get device configuration. Permits to retrieve at run-time configuration
- * values that were used to initialize and configure the device.
- */
-enum vxge_hw_status
-vxge_hw_mgmt_device_config(struct __vxge_hw_device *hldev,
-                          struct vxge_hw_device_config *dev_config, int size)
-{
-
-       if ((hldev == NULL) || (hldev->magic != VXGE_HW_DEVICE_MAGIC))
-               return VXGE_HW_ERR_INVALID_DEVICE;
-
-       if (size != sizeof(struct vxge_hw_device_config))
-               return VXGE_HW_ERR_VERSION_CONFLICT;
-
-       memcpy(dev_config, &hldev->config,
-               sizeof(struct vxge_hw_device_config));
-
-       return VXGE_HW_OK;
-}
-
 /*
  * vxge_hw_mgmt_reg_read - Read Titan register.
  */
@@ -2438,7 +2575,7 @@ exit:
  * __vxge_hw_fifo_abort - Returns the TxD
  * This function terminates the TxDs of fifo
  */
-enum vxge_hw_status __vxge_hw_fifo_abort(struct __vxge_hw_fifo *fifo)
+static enum vxge_hw_status __vxge_hw_fifo_abort(struct __vxge_hw_fifo *fifo)
 {
        void *txdlh;
 
@@ -2466,7 +2603,7 @@ enum vxge_hw_status __vxge_hw_fifo_abort(struct __vxge_hw_fifo *fifo)
  * __vxge_hw_fifo_reset - Resets the fifo
  * This function resets the fifo during vpath reset operation
  */
-enum vxge_hw_status __vxge_hw_fifo_reset(struct __vxge_hw_fifo *fifo)
+static enum vxge_hw_status __vxge_hw_fifo_reset(struct __vxge_hw_fifo *fifo)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
 
@@ -2501,7 +2638,7 @@ enum vxge_hw_status __vxge_hw_fifo_delete(struct __vxge_hw_vpath_handle *vp)
  *                          in pci config space.
  * Read from the vpath pci config space.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_pci_read(struct __vxge_hw_virtualpath *vpath,
                         u32 phy_func_0, u32 offset, u32 *val)
 {
@@ -2542,7 +2679,7 @@ exit:
  * __vxge_hw_vpath_func_id_get - Get the function id of the vpath.
  * Returns the function number of the vpath.
  */
-u32
+static u32
 __vxge_hw_vpath_func_id_get(u32 vp_id,
        struct vxge_hw_vpmgmt_reg __iomem *vpmgmt_reg)
 {
@@ -2573,7 +2710,7 @@ __vxge_hw_read_rts_ds(struct vxge_hw_vpath_reg __iomem *vpath_reg,
  * __vxge_hw_vpath_card_info_get - Get the serial numbers,
  * part number and product description.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_card_info_get(
        u32 vp_id,
        struct vxge_hw_vpath_reg __iomem *vpath_reg,
@@ -2695,7 +2832,7 @@ __vxge_hw_vpath_card_info_get(
  * __vxge_hw_vpath_fw_ver_get - Get the fw version
  * Returns FW Version
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_fw_ver_get(
        u32 vp_id,
        struct vxge_hw_vpath_reg __iomem *vpath_reg,
@@ -2789,7 +2926,7 @@ exit:
  * __vxge_hw_vpath_pci_func_mode_get - Get the pci mode
  * Returns pci function mode
  */
-u64
+static u64
 __vxge_hw_vpath_pci_func_mode_get(
        u32  vp_id,
        struct vxge_hw_vpath_reg __iomem *vpath_reg)
@@ -2995,7 +3132,7 @@ exit:
  * __vxge_hw_vpath_addr_get - Get the hw address entry for this vpath
  *               from MAC address table.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_addr_get(
        u32 vp_id, struct vxge_hw_vpath_reg __iomem *vpath_reg,
        u8 (macaddr)[ETH_ALEN], u8 (macaddr_mask)[ETH_ALEN])
@@ -3347,7 +3484,7 @@ __vxge_hw_vpath_mgmt_read(
  * This routine checks the vpath_rst_in_prog register to see if
  * adapter completed the reset process for the vpath
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_reset_check(struct __vxge_hw_virtualpath *vpath)
 {
        enum vxge_hw_status status;
@@ -3365,7 +3502,7 @@ __vxge_hw_vpath_reset_check(struct __vxge_hw_virtualpath *vpath)
  * __vxge_hw_vpath_reset
  * This routine resets the vpath on the device
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_reset(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -3383,7 +3520,7 @@ __vxge_hw_vpath_reset(struct __vxge_hw_device *hldev, u32 vp_id)
  * __vxge_hw_vpath_sw_reset
  * This routine resets the vpath structures
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_sw_reset(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
@@ -3408,7 +3545,7 @@ exit:
  * This routine configures the prc registers of virtual path using the config
  * passed
  */
-void
+static void
 __vxge_hw_vpath_prc_configure(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -3480,7 +3617,7 @@ __vxge_hw_vpath_prc_configure(struct __vxge_hw_device *hldev, u32 vp_id)
  * This routine configures the kdfc registers of virtual path using the
  * config passed
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_kdfc_configure(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -3553,7 +3690,7 @@ exit:
  * __vxge_hw_vpath_mac_configure
  * This routine configures the mac of virtual path using the config passed
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_mac_configure(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -3621,7 +3758,7 @@ __vxge_hw_vpath_mac_configure(struct __vxge_hw_device *hldev, u32 vp_id)
  * This routine configures the tim registers of virtual path using the config
  * passed
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_tim_configure(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -3897,7 +4034,7 @@ vxge_hw_vpath_tti_ci_set(struct __vxge_hw_device *hldev, u32 vp_id)
  * This routine is the final phase of init which initializes the
  * registers of the vpath using the configuration passed.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_initialize(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -3966,7 +4103,7 @@ exit:
  * This routine is the initial phase of init which resets the vpath and
  * initializes the software support structures.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vp_initialize(struct __vxge_hw_device *hldev, u32 vp_id,
                        struct vxge_hw_vp_config *config)
 {
@@ -4022,7 +4159,7 @@ exit:
  * __vxge_hw_vp_terminate - Terminate Virtual Path structure
  * This routine closes all channels it opened and freeup memory
  */
-void
+static void
 __vxge_hw_vp_terminate(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        struct __vxge_hw_virtualpath *vpath;
@@ -4384,7 +4521,7 @@ vxge_hw_vpath_enable(struct __vxge_hw_vpath_handle *vp)
  * Enable the DMA vpath statistics. The function is to be called to re-enable
  * the adapter to update stats into the host memory
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_hw_vpath_stats_enable(struct __vxge_hw_vpath_handle *vp)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
@@ -4409,7 +4546,7 @@ exit:
  * __vxge_hw_vpath_stats_access - Get the statistics from the given location
  *                           and offset and perform an operation
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_stats_access(struct __vxge_hw_virtualpath *vpath,
                             u32 operation, u32 offset, u64 *stat)
 {
@@ -4445,7 +4582,7 @@ vpath_stats_access_exit:
 /*
  * __vxge_hw_vpath_xmac_tx_stats_get - Get the TX Statistics of a vpath
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_xmac_tx_stats_get(
        struct __vxge_hw_virtualpath *vpath,
        struct vxge_hw_xmac_vpath_tx_stats *vpath_tx_stats)
@@ -4478,9 +4615,9 @@ exit:
 /*
  * __vxge_hw_vpath_xmac_rx_stats_get - Get the RX Statistics of a vpath
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_xmac_rx_stats_get(struct __vxge_hw_virtualpath *vpath,
-                       struct vxge_hw_xmac_vpath_rx_stats *vpath_rx_stats)
+                                 struct vxge_hw_xmac_vpath_rx_stats *vpath_rx_stats)
 {
        u64 *val64;
        enum vxge_hw_status status = VXGE_HW_OK;
@@ -4509,9 +4646,9 @@ exit:
 /*
  * __vxge_hw_vpath_stats_get - Get the vpath hw statistics.
  */
-enum vxge_hw_status __vxge_hw_vpath_stats_get(
-                       struct __vxge_hw_virtualpath *vpath,
-                       struct vxge_hw_vpath_stats_hw_info *hw_stats)
+static enum vxge_hw_status
+__vxge_hw_vpath_stats_get(struct __vxge_hw_virtualpath *vpath,
+                         struct vxge_hw_vpath_stats_hw_info *hw_stats)
 {
        u64 val64;
        enum vxge_hw_status status = VXGE_HW_OK;
@@ -4643,6 +4780,32 @@ exit:
        return status;
 }
 
+
+static void vxge_os_dma_malloc_async(struct pci_dev *pdev, void *devh,
+                                       unsigned long size)
+{
+       gfp_t flags;
+       void *vaddr;
+
+       if (in_interrupt())
+               flags = GFP_ATOMIC | GFP_DMA;
+       else
+               flags = GFP_KERNEL | GFP_DMA;
+
+       vaddr = kmalloc((size), flags);
+
+       vxge_hw_blockpool_block_add(devh, vaddr, size, pdev, pdev);
+}
+
+static void vxge_os_dma_free(struct pci_dev *pdev, const void *vaddr,
+                            struct pci_dev **p_dma_acch)
+{
+       unsigned long misaligned = *(unsigned long *)p_dma_acch;
+       u8 *tmp = (u8 *)vaddr;
+       tmp -= misaligned;
+       kfree((void *)tmp);
+}
+
 /*
  * __vxge_hw_blockpool_create - Create block pool
  */
@@ -4845,12 +5008,11 @@ void __vxge_hw_blockpool_blocks_remove(struct __vxge_hw_blockpool *blockpool)
  * vxge_hw_blockpool_block_add - callback for vxge_os_dma_malloc_async
  * Adds a block to block pool
  */
-void vxge_hw_blockpool_block_add(
-                       struct __vxge_hw_device *devh,
-                       void *block_addr,
-                       u32 length,
-                       struct pci_dev *dma_h,
-                       struct pci_dev *acc_handle)
+static void vxge_hw_blockpool_block_add(struct __vxge_hw_device *devh,
+                                       void *block_addr,
+                                       u32 length,
+                                       struct pci_dev *dma_h,
+                                       struct pci_dev *acc_handle)
 {
        struct __vxge_hw_blockpool  *blockpool;
        struct __vxge_hw_blockpool_entry  *entry = NULL;
index 1a94343023cb20fdb7f0f3a5b4d4b83ab1b9e1b3..5c00861b6c2c08351f1f52023f4037dfaad45236 100644 (file)
@@ -183,11 +183,6 @@ struct vxge_hw_device_version {
        char    version[VXGE_HW_FW_STRLEN];
 };
 
-u64
-__vxge_hw_vpath_pci_func_mode_get(
-       u32 vp_id,
-       struct vxge_hw_vpath_reg __iomem *vpath_reg);
-
 /**
  * struct vxge_hw_fifo_config - Configuration of fifo.
  * @enable: Is this fifo to be commissioned
@@ -1426,9 +1421,6 @@ struct vxge_hw_rth_hash_types {
        u8 hash_type_ipv6ex_en;
 };
 
-u32
-vxge_hw_device_debug_mask_get(struct __vxge_hw_device *devh);
-
 void vxge_hw_device_debug_set(
        struct __vxge_hw_device *devh,
        enum vxge_debug_level level,
@@ -1440,9 +1432,6 @@ vxge_hw_device_error_level_get(struct __vxge_hw_device *devh);
 u32
 vxge_hw_device_trace_level_get(struct __vxge_hw_device *devh);
 
-u32
-vxge_hw_device_debug_mask_get(struct __vxge_hw_device *devh);
-
 /**
  * vxge_hw_ring_rxd_size_get   - Get the size of ring descriptor.
  * @buf_mode: Buffer mode (1, 3 or 5)
@@ -1817,60 +1806,10 @@ struct vxge_hw_vpath_attr {
        struct vxge_hw_fifo_attr        fifo_attr;
 };
 
-enum vxge_hw_status
-__vxge_hw_blockpool_create(struct __vxge_hw_device *hldev,
-                       struct __vxge_hw_blockpool  *blockpool,
-                       u32 pool_size,
-                       u32 pool_max);
-
-void
-__vxge_hw_blockpool_destroy(struct __vxge_hw_blockpool  *blockpool);
-
-struct __vxge_hw_blockpool_entry *
-__vxge_hw_blockpool_block_allocate(struct __vxge_hw_device *hldev,
-                       u32 size);
-
-void
-__vxge_hw_blockpool_block_free(struct __vxge_hw_device *hldev,
-                       struct __vxge_hw_blockpool_entry *entry);
-
-void *
-__vxge_hw_blockpool_malloc(struct __vxge_hw_device *hldev,
-                       u32 size,
-                       struct vxge_hw_mempool_dma *dma_object);
-
-void
-__vxge_hw_blockpool_free(struct __vxge_hw_device *hldev,
-                       void *memblock,
-                       u32 size,
-                       struct vxge_hw_mempool_dma *dma_object);
-
-enum vxge_hw_status
-__vxge_hw_device_fifo_config_check(struct vxge_hw_fifo_config *fifo_config);
-
-enum vxge_hw_status
-__vxge_hw_device_config_check(struct vxge_hw_device_config *new_config);
-
-enum vxge_hw_status
-vxge_hw_mgmt_device_config(struct __vxge_hw_device *devh,
-               struct vxge_hw_device_config    *dev_config, int size);
-
 enum vxge_hw_status __devinit vxge_hw_device_hw_info_get(
        void __iomem *bar0,
        struct vxge_hw_device_hw_info *hw_info);
 
-enum vxge_hw_status
-__vxge_hw_vpath_fw_ver_get(
-       u32     vp_id,
-       struct vxge_hw_vpath_reg __iomem *vpath_reg,
-       struct vxge_hw_device_hw_info *hw_info);
-
-enum vxge_hw_status
-__vxge_hw_vpath_card_info_get(
-       u32 vp_id,
-       struct vxge_hw_vpath_reg __iomem *vpath_reg,
-       struct vxge_hw_device_hw_info *hw_info);
-
 enum vxge_hw_status __devinit vxge_hw_device_config_default_get(
        struct vxge_hw_device_config *device_config);
 
@@ -1954,38 +1893,6 @@ out:
        return vaddr;
 }
 
-extern void vxge_hw_blockpool_block_add(
-                       struct __vxge_hw_device *devh,
-                       void *block_addr,
-                       u32 length,
-                       struct pci_dev *dma_h,
-                       struct pci_dev *acc_handle);
-
-static inline void vxge_os_dma_malloc_async(struct pci_dev *pdev, void *devh,
-                                       unsigned long size)
-{
-       gfp_t flags;
-       void *vaddr;
-
-       if (in_interrupt())
-               flags = GFP_ATOMIC | GFP_DMA;
-       else
-               flags = GFP_KERNEL | GFP_DMA;
-
-       vaddr = kmalloc((size), flags);
-
-       vxge_hw_blockpool_block_add(devh, vaddr, size, pdev, pdev);
-}
-
-static inline void vxge_os_dma_free(struct pci_dev *pdev, const void *vaddr,
-                       struct pci_dev **p_dma_acch)
-{
-       unsigned long misaligned = *(unsigned long *)p_dma_acch;
-       u8 *tmp = (u8 *)vaddr;
-       tmp -= misaligned;
-       kfree((void *)tmp);
-}
-
 /*
  * __vxge_hw_mempool_item_priv - will return pointer on per item private space
  */
@@ -2010,40 +1917,6 @@ __vxge_hw_mempool_item_priv(
                            (*memblock_item_idx) * mempool->items_priv_size;
 }
 
-enum vxge_hw_status
-__vxge_hw_mempool_grow(
-       struct vxge_hw_mempool *mempool,
-       u32 num_allocate,
-       u32 *num_allocated);
-
-struct vxge_hw_mempool*
-__vxge_hw_mempool_create(
-       struct __vxge_hw_device *devh,
-       u32 memblock_size,
-       u32 item_size,
-       u32 private_size,
-       u32 items_initial,
-       u32 items_max,
-       struct vxge_hw_mempool_cbs *mp_callback,
-       void *userdata);
-
-struct __vxge_hw_channel*
-__vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph,
-                       enum __vxge_hw_channel_type type, u32 length,
-                       u32 per_dtr_space, void *userdata);
-
-void
-__vxge_hw_channel_free(
-       struct __vxge_hw_channel *channel);
-
-enum vxge_hw_status
-__vxge_hw_channel_initialize(
-       struct __vxge_hw_channel *channel);
-
-enum vxge_hw_status
-__vxge_hw_channel_reset(
-       struct __vxge_hw_channel *channel);
-
 /*
  * __vxge_hw_fifo_txdl_priv - Return the max fragments allocated
  * for the fifo.
@@ -2065,9 +1938,6 @@ enum vxge_hw_status vxge_hw_vpath_open(
        struct vxge_hw_vpath_attr *attr,
        struct __vxge_hw_vpath_handle **vpath_handle);
 
-enum vxge_hw_status
-__vxge_hw_device_vpath_reset_in_prog_check(u64 __iomem *vpath_rst_in_prog);
-
 enum vxge_hw_status vxge_hw_vpath_close(
        struct __vxge_hw_vpath_handle *vpath_handle);
 
@@ -2089,54 +1959,9 @@ enum vxge_hw_status vxge_hw_vpath_mtu_set(
        struct __vxge_hw_vpath_handle *vpath_handle,
        u32 new_mtu);
 
-enum vxge_hw_status vxge_hw_vpath_stats_enable(
-       struct __vxge_hw_vpath_handle *vpath_handle);
-
-enum vxge_hw_status
-__vxge_hw_vpath_stats_access(
-       struct __vxge_hw_virtualpath    *vpath,
-       u32                     operation,
-       u32                     offset,
-       u64                     *stat);
-
-enum vxge_hw_status
-__vxge_hw_vpath_xmac_tx_stats_get(
-       struct __vxge_hw_virtualpath    *vpath,
-       struct vxge_hw_xmac_vpath_tx_stats *vpath_tx_stats);
-
-enum vxge_hw_status
-__vxge_hw_vpath_xmac_rx_stats_get(
-       struct __vxge_hw_virtualpath    *vpath,
-       struct vxge_hw_xmac_vpath_rx_stats *vpath_rx_stats);
-
-enum vxge_hw_status
-__vxge_hw_vpath_stats_get(
-       struct __vxge_hw_virtualpath *vpath,
-       struct vxge_hw_vpath_stats_hw_info *hw_stats);
-
 void
 vxge_hw_vpath_rx_doorbell_init(struct __vxge_hw_vpath_handle *vp);
 
-enum vxge_hw_status
-__vxge_hw_device_vpath_config_check(struct vxge_hw_vp_config *vp_config);
-
-void
-__vxge_hw_device_pci_e_init(struct __vxge_hw_device *hldev);
-
-enum vxge_hw_status
-__vxge_hw_legacy_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg);
-
-enum vxge_hw_status
-__vxge_hw_vpath_swapper_set(struct vxge_hw_vpath_reg __iomem *vpath_reg);
-
-enum vxge_hw_status
-__vxge_hw_kdfc_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg,
-       struct vxge_hw_vpath_reg __iomem *vpath_reg);
-
-enum vxge_hw_status
-__vxge_hw_device_register_poll(
-       void __iomem    *reg,
-       u64 mask, u32 max_millis);
 
 #ifndef readq
 static inline u64 readq(void __iomem *addr)
@@ -2168,62 +1993,12 @@ static inline void __vxge_hw_pio_mem_write32_lower(u32 val, void __iomem *addr)
        writel(val, addr);
 }
 
-static inline enum vxge_hw_status
-__vxge_hw_pio_mem_write64(u64 val64, void __iomem *addr,
-                         u64 mask, u32 max_millis)
-{
-       enum vxge_hw_status status = VXGE_HW_OK;
-
-       __vxge_hw_pio_mem_write32_lower((u32)vxge_bVALn(val64, 32, 32), addr);
-       wmb();
-       __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(val64, 0, 32), addr);
-       wmb();
-
-       status = __vxge_hw_device_register_poll(addr, mask, max_millis);
-       return status;
-}
-
-struct vxge_hw_toc_reg __iomem *
-__vxge_hw_device_toc_get(void __iomem *bar0);
-
-enum vxge_hw_status
-__vxge_hw_device_reg_addr_get(struct __vxge_hw_device *hldev);
-
-void
-__vxge_hw_device_id_get(struct __vxge_hw_device *hldev);
-
-void
-__vxge_hw_device_host_info_get(struct __vxge_hw_device *hldev);
-
 enum vxge_hw_status
 vxge_hw_device_flick_link_led(struct __vxge_hw_device *devh, u64 on_off);
 
-enum vxge_hw_status
-__vxge_hw_device_initialize(struct __vxge_hw_device *hldev);
-
-enum vxge_hw_status
-__vxge_hw_vpath_pci_read(
-       struct __vxge_hw_virtualpath    *vpath,
-       u32                     phy_func_0,
-       u32                     offset,
-       u32                     *val);
-
-enum vxge_hw_status
-__vxge_hw_vpath_addr_get(
-       u32 vp_id,
-       struct vxge_hw_vpath_reg __iomem *vpath_reg,
-       u8 (macaddr)[ETH_ALEN],
-       u8 (macaddr_mask)[ETH_ALEN]);
-
-u32
-__vxge_hw_vpath_func_id_get(
-       u32 vp_id, struct vxge_hw_vpmgmt_reg __iomem *vpmgmt_reg);
-
-enum vxge_hw_status
-__vxge_hw_vpath_reset_check(struct __vxge_hw_virtualpath *vpath);
-
 enum vxge_hw_status
 vxge_hw_vpath_strip_fcs_check(struct __vxge_hw_device *hldev, u64 vpath_mask);
+
 /**
  * vxge_debug
  * @level: level of debug verbosity.
index 05679e306fdd5711bc15831fda2d95c0fe54c81a..b67746eef923e2cdeb9886130796e375d3b34818 100644 (file)
@@ -1142,7 +1142,7 @@ static const struct ethtool_ops vxge_ethtool_ops = {
        .get_ethtool_stats      = vxge_get_ethtool_stats,
 };
 
-void initialize_ethtool_ops(struct net_device *ndev)
+void vxge_initialize_ethtool_ops(struct net_device *ndev)
 {
        SET_ETHTOOL_OPS(ndev, &vxge_ethtool_ops);
 }
index a69542ecb68de8592e7f9791d4c627104caba046..813829f3d0242be97ff22f97bf1724b7db3c8734 100644 (file)
@@ -82,6 +82,16 @@ module_param_array(bw_percentage, uint, NULL, 0);
 
 static struct vxge_drv_config *driver_config;
 
+static enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev,
+                                            struct macInfo *mac);
+static enum vxge_hw_status vxge_del_mac_addr(struct vxgedev *vdev,
+                                            struct macInfo *mac);
+static int vxge_mac_list_add(struct vxge_vpath *vpath, struct macInfo *mac);
+static int vxge_mac_list_del(struct vxge_vpath *vpath, struct macInfo *mac);
+static enum vxge_hw_status vxge_restore_vpath_vid_table(struct vxge_vpath *vpath);
+static enum vxge_hw_status vxge_restore_vpath_mac_addr(struct vxge_vpath *vpath);
+static enum vxge_hw_status vxge_reset_all_vpaths(struct vxgedev *vdev);
+
 static inline int is_vxge_card_up(struct vxgedev *vdev)
 {
        return test_bit(__VXGE_STATE_CARD_UP, &vdev->state);
@@ -138,7 +148,7 @@ static inline void VXGE_COMPLETE_ALL_RX(struct vxgedev *vdev)
  * This function is called during interrupt context to notify link up state
  * change.
  */
-void
+static void
 vxge_callback_link_up(struct __vxge_hw_device *hldev)
 {
        struct net_device *dev = hldev->ndev;
@@ -162,7 +172,7 @@ vxge_callback_link_up(struct __vxge_hw_device *hldev)
  * This function is called during interrupt context to notify link down state
  * change.
  */
-void
+static void
 vxge_callback_link_down(struct __vxge_hw_device *hldev)
 {
        struct net_device *dev = hldev->ndev;
@@ -354,7 +364,7 @@ static inline void vxge_post(int *dtr_cnt, void **first_dtr,
  * If the interrupt is because of a received frame or if the receive ring
  * contains fresh as yet un-processed frames, this function is called.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_rx_1b_compl(struct __vxge_hw_ring *ringh, void *dtr,
                 u8 t_code, void *userdata)
 {
@@ -531,7 +541,7 @@ vxge_rx_1b_compl(struct __vxge_hw_ring *ringh, void *dtr,
  * freed and frees all skbs whose data have already DMA'ed into the NICs
  * internal memory.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_xmit_compl(struct __vxge_hw_fifo *fifo_hw, void *dtr,
                enum vxge_hw_fifo_tcode t_code, void *userdata,
                struct sk_buff ***skb_ptr, int nr_skb, int *more)
@@ -1246,7 +1256,7 @@ static int vxge_set_mac_addr(struct net_device *dev, void *p)
  *
  * Enables the interrupts for the vpath
 */
-void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id)
+static void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id)
 {
        struct vxge_vpath *vpath = &vdev->vpaths[vp_id];
        int msix_id = 0;
@@ -1279,7 +1289,7 @@ void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id)
  *
  * Disables the interrupts for the vpath
 */
-void vxge_vpath_intr_disable(struct vxgedev *vdev, int vp_id)
+static void vxge_vpath_intr_disable(struct vxgedev *vdev, int vp_id)
 {
        struct vxge_vpath *vpath = &vdev->vpaths[vp_id];
        int msix_id;
@@ -1553,7 +1563,7 @@ out:
  *
  * driver may reset the chip on events of serr, eccerr, etc
  */
-int vxge_reset(struct vxgedev *vdev)
+static int vxge_reset(struct vxgedev *vdev)
 {
        return do_vxge_reset(vdev, VXGE_LL_FULL_RESET);
 }
@@ -1724,7 +1734,7 @@ static enum vxge_hw_status vxge_rth_configure(struct vxgedev *vdev)
        return status;
 }
 
-int vxge_mac_list_add(struct vxge_vpath *vpath, struct macInfo *mac)
+static int vxge_mac_list_add(struct vxge_vpath *vpath, struct macInfo *mac)
 {
        struct vxge_mac_addrs *new_mac_entry;
        u8 *mac_address = NULL;
@@ -1757,7 +1767,8 @@ int vxge_mac_list_add(struct vxge_vpath *vpath, struct macInfo *mac)
 }
 
 /* Add a mac address to DA table */
-enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev, struct macInfo *mac)
+static enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev,
+                                            struct macInfo *mac)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
        struct vxge_vpath *vpath;
@@ -1782,7 +1793,7 @@ enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev, struct macInfo *mac)
        return status;
 }
 
-int vxge_mac_list_del(struct vxge_vpath *vpath, struct macInfo *mac)
+static int vxge_mac_list_del(struct vxge_vpath *vpath, struct macInfo *mac)
 {
        struct list_head *entry, *next;
        u64 del_mac = 0;
@@ -1807,7 +1818,8 @@ int vxge_mac_list_del(struct vxge_vpath *vpath, struct macInfo *mac)
        return FALSE;
 }
 /* delete a mac address from DA table */
-enum vxge_hw_status vxge_del_mac_addr(struct vxgedev *vdev, struct macInfo *mac)
+static enum vxge_hw_status vxge_del_mac_addr(struct vxgedev *vdev,
+                                            struct macInfo *mac)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
        struct vxge_vpath *vpath;
@@ -1854,7 +1866,7 @@ static vxge_search_mac_addr_in_da_table(struct vxge_vpath *vpath,
 }
 
 /* Store all vlan ids from the list to the vid table */
-enum vxge_hw_status vxge_restore_vpath_vid_table(struct vxge_vpath *vpath)
+static enum vxge_hw_status vxge_restore_vpath_vid_table(struct vxge_vpath *vpath)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
        struct vxgedev *vdev = vpath->vdev;
@@ -1874,7 +1886,7 @@ enum vxge_hw_status vxge_restore_vpath_vid_table(struct vxge_vpath *vpath)
 }
 
 /* Store all mac addresses from the list to the DA table */
-enum vxge_hw_status vxge_restore_vpath_mac_addr(struct vxge_vpath *vpath)
+static enum vxge_hw_status vxge_restore_vpath_mac_addr(struct vxge_vpath *vpath)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
        struct macInfo mac_info;
@@ -1916,7 +1928,7 @@ enum vxge_hw_status vxge_restore_vpath_mac_addr(struct vxge_vpath *vpath)
 }
 
 /* reset vpaths */
-enum vxge_hw_status vxge_reset_all_vpaths(struct vxgedev *vdev)
+static enum vxge_hw_status vxge_reset_all_vpaths(struct vxgedev *vdev)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
        struct vxge_vpath *vpath;
@@ -1948,7 +1960,7 @@ enum vxge_hw_status vxge_reset_all_vpaths(struct vxgedev *vdev)
 }
 
 /* close vpaths */
-void vxge_close_vpaths(struct vxgedev *vdev, int index)
+static void vxge_close_vpaths(struct vxgedev *vdev, int index)
 {
        struct vxge_vpath *vpath;
        int i;
@@ -1966,7 +1978,7 @@ void vxge_close_vpaths(struct vxgedev *vdev, int index)
 }
 
 /* open vpaths */
-int vxge_open_vpaths(struct vxgedev *vdev)
+static int vxge_open_vpaths(struct vxgedev *vdev)
 {
        struct vxge_hw_vpath_attr attr;
        enum vxge_hw_status status;
@@ -2517,7 +2529,7 @@ static void vxge_poll_vp_lockup(unsigned long data)
  * Return value: '0' on success and an appropriate (-)ve integer as
  * defined in errno.h file on failure.
  */
-int
+static int
 vxge_open(struct net_device *dev)
 {
        enum vxge_hw_status status;
@@ -2721,7 +2733,7 @@ out0:
 }
 
 /* Loop throught the mac address list and delete all the entries */
-void vxge_free_mac_add_list(struct vxge_vpath *vpath)
+static void vxge_free_mac_add_list(struct vxge_vpath *vpath)
 {
 
        struct list_head *entry, *next;
@@ -2745,7 +2757,7 @@ static void vxge_napi_del_all(struct vxgedev *vdev)
        }
 }
 
-int do_vxge_close(struct net_device *dev, int do_io)
+static int do_vxge_close(struct net_device *dev, int do_io)
 {
        enum vxge_hw_status status;
        struct vxgedev *vdev;
@@ -2856,7 +2868,7 @@ int do_vxge_close(struct net_device *dev, int do_io)
  * Return value: '0' on success and an appropriate (-)ve integer as
  * defined in errno.h file on failure.
  */
-int
+static int
 vxge_close(struct net_device *dev)
 {
        do_vxge_close(dev, 1);
@@ -3113,10 +3125,10 @@ static const struct net_device_ops vxge_netdev_ops = {
 #endif
 };
 
-int __devinit vxge_device_register(struct __vxge_hw_device *hldev,
-                                  struct vxge_config *config,
-                                  int high_dma, int no_of_vpath,
-                                  struct vxgedev **vdev_out)
+static int __devinit vxge_device_register(struct __vxge_hw_device *hldev,
+                                         struct vxge_config *config,
+                                         int high_dma, int no_of_vpath,
+                                         struct vxgedev **vdev_out)
 {
        struct net_device *ndev;
        enum vxge_hw_status status = VXGE_HW_OK;
@@ -3164,7 +3176,7 @@ int __devinit vxge_device_register(struct __vxge_hw_device *hldev,
 
        ndev->watchdog_timeo = VXGE_LL_WATCH_DOG_TIMEOUT;
 
-       initialize_ethtool_ops(ndev);
+       vxge_initialize_ethtool_ops(ndev);
 
        /* Allocate memory for vpath */
        vdev->vpaths = kzalloc((sizeof(struct vxge_vpath)) *
@@ -3249,7 +3261,7 @@ _out0:
  *
  * This function will unregister and free network device
  */
-void
+static void
 vxge_device_unregister(struct __vxge_hw_device *hldev)
 {
        struct vxgedev *vdev;
index d4be07eaacd72d007faa4cfdeba4dc61bf645ee8..de64536cb7d0d1c32943b6d7b64762e306f8bcb8 100644 (file)
@@ -396,64 +396,7 @@ struct vxge_tx_priv {
                mod_timer(&timer, (jiffies + exp)); \
        } while (0);
 
-int __devinit vxge_device_register(struct __vxge_hw_device *devh,
-                                   struct vxge_config *config,
-                                   int high_dma, int no_of_vpath,
-                                   struct vxgedev **vdev);
-
-void vxge_device_unregister(struct __vxge_hw_device *devh);
-
-void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id);
-
-void vxge_vpath_intr_disable(struct vxgedev *vdev, int vp_id);
-
-void vxge_callback_link_up(struct __vxge_hw_device *devh);
-
-void vxge_callback_link_down(struct __vxge_hw_device *devh);
-
-enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev,
-       struct macInfo *mac);
-
-int vxge_mac_list_del(struct vxge_vpath *vpath, struct macInfo *mac);
-
-int vxge_reset(struct vxgedev *vdev);
-
-enum vxge_hw_status
-vxge_rx_1b_compl(struct __vxge_hw_ring *ringh, void *dtr,
-       u8 t_code, void *userdata);
-
-enum vxge_hw_status
-vxge_xmit_compl(struct __vxge_hw_fifo *fifo_hw, void *dtr,
-       enum vxge_hw_fifo_tcode t_code, void *userdata,
-       struct sk_buff ***skb_ptr, int nr_skbs, int *more);
-
-int vxge_close(struct net_device *dev);
-
-int vxge_open(struct net_device *dev);
-
-void vxge_close_vpaths(struct vxgedev *vdev, int index);
-
-int vxge_open_vpaths(struct vxgedev *vdev);
-
-enum vxge_hw_status vxge_reset_all_vpaths(struct vxgedev *vdev);
-
-enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev,
-       struct macInfo *mac);
-
-enum vxge_hw_status vxge_del_mac_addr(struct vxgedev *vdev,
-       struct macInfo *mac);
-
-int vxge_mac_list_add(struct vxge_vpath *vpath,
-       struct macInfo *mac);
-
-void vxge_free_mac_add_list(struct vxge_vpath *vpath);
-
-enum vxge_hw_status vxge_restore_vpath_mac_addr(struct vxge_vpath *vpath);
-
-enum vxge_hw_status vxge_restore_vpath_vid_table(struct vxge_vpath *vpath);
-
-int do_vxge_close(struct net_device *dev, int do_io);
-extern void initialize_ethtool_ops(struct net_device *ndev);
+extern void vxge_initialize_ethtool_ops(struct net_device *ndev);
 /**
  * #define VXGE_DEBUG_INIT: debug for initialization functions
  * #define VXGE_DEBUG_TX        : debug transmit related functions
index cedf08f99cb3dbf2a2b94e198ef168c4102dc6a5..4bdb611a6842dd6c5bd6a0f7a2a1893c254869f5 100644 (file)
 #include "vxge-config.h"
 #include "vxge-main.h"
 
+static enum vxge_hw_status
+__vxge_hw_device_handle_error(struct __vxge_hw_device *hldev,
+                             u32 vp_id, enum vxge_hw_event type);
+static enum vxge_hw_status
+__vxge_hw_vpath_alarm_process(struct __vxge_hw_virtualpath *vpath,
+                             u32 skip_alarms);
+
 /*
  * vxge_hw_vpath_intr_enable - Enable vpath interrupts.
  * @vp: Virtual Path handle.
@@ -513,7 +520,7 @@ exit:
  * Link up indication handler. The function is invoked by HW when
  * Titan indicates that the link is up for programmable amount of time.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_device_handle_link_up_ind(struct __vxge_hw_device *hldev)
 {
        /*
@@ -538,7 +545,7 @@ exit:
  * Link down indication handler. The function is invoked by HW when
  * Titan indicates that the link is down.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_device_handle_link_down_ind(struct __vxge_hw_device *hldev)
 {
        /*
@@ -564,7 +571,7 @@ exit:
  *
  * Handle error.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_device_handle_error(
                struct __vxge_hw_device *hldev,
                u32 vp_id,
@@ -646,7 +653,7 @@ void vxge_hw_device_clear_tx_rx(struct __vxge_hw_device *hldev)
  * it swaps the reserve and free arrays.
  *
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_hw_channel_dtr_alloc(struct __vxge_hw_channel *channel, void **dtrh)
 {
        void **tmp_arr;
@@ -692,7 +699,8 @@ _alloc_after_swap:
  * Posts a dtr to work array.
  *
  */
-void vxge_hw_channel_dtr_post(struct __vxge_hw_channel *channel, void *dtrh)
+static void vxge_hw_channel_dtr_post(struct __vxge_hw_channel *channel,
+                                    void *dtrh)
 {
        vxge_assert(channel->work_arr[channel->post_index] == NULL);
 
@@ -1657,37 +1665,6 @@ exit:
        return status;
 }
 
-/**
- * vxge_hw_vpath_vid_get_next - Get the next vid entry for this vpath
- *               from vlan id table.
- * @vp: Vpath handle.
- * @vid: Buffer to return vlan id
- *
- * Returns the next vlan id in the list for this vpath.
- * see also: vxge_hw_vpath_vid_get
- *
- */
-enum vxge_hw_status
-vxge_hw_vpath_vid_get_next(struct __vxge_hw_vpath_handle *vp, u64 *vid)
-{
-       u64 data;
-       enum vxge_hw_status status = VXGE_HW_OK;
-
-       if (vp == NULL) {
-               status = VXGE_HW_ERR_INVALID_HANDLE;
-               goto exit;
-       }
-
-       status = __vxge_hw_vpath_rts_table_get(vp,
-                       VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_LIST_NEXT_ENTRY,
-                       VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_VID,
-                       0, vid, &data);
-
-       *vid = VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_VLAN_ID(*vid);
-exit:
-       return status;
-}
-
 /**
  * vxge_hw_vpath_vid_delete - Delete the vlan id entry for this vpath
  *               to vlan id table.
@@ -1898,9 +1875,9 @@ exit:
  * Process vpath alarms.
  *
  */
-enum vxge_hw_status __vxge_hw_vpath_alarm_process(
-                       struct __vxge_hw_virtualpath *vpath,
-                       u32 skip_alarms)
+static enum vxge_hw_status
+__vxge_hw_vpath_alarm_process(struct __vxge_hw_virtualpath *vpath,
+                             u32 skip_alarms)
 {
        u64 val64;
        u64 alarm_status;
@@ -2264,36 +2241,6 @@ vxge_hw_vpath_msix_mask(struct __vxge_hw_vpath_handle *vp, int msix_id)
                &hldev->common_reg->set_msix_mask_vect[msix_id % 4]);
 }
 
-/**
- * vxge_hw_vpath_msix_clear - Clear MSIX Vector.
- * @vp: Virtual Path handle.
- * @msix_id:  MSI ID
- *
- * The function clears the msix interrupt for the given msix_id
- *
- * Returns: 0,
- * Otherwise, VXGE_HW_ERR_WRONG_IRQ if the msix index is out of range
- * status.
- * See also:
- */
-void
-vxge_hw_vpath_msix_clear(struct __vxge_hw_vpath_handle *vp, int msix_id)
-{
-       struct __vxge_hw_device *hldev = vp->vpath->hldev;
-       if (hldev->config.intr_mode ==
-                       VXGE_HW_INTR_MODE_MSIX_ONE_SHOT) {
-               __vxge_hw_pio_mem_write32_upper(
-                       (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
-                               &hldev->common_reg->
-                                       clr_msix_one_shot_vec[msix_id%4]);
-       } else {
-               __vxge_hw_pio_mem_write32_upper(
-                       (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
-                               &hldev->common_reg->
-                                       clear_msix_mask_vect[msix_id%4]);
-       }
-}
-
 /**
  * vxge_hw_vpath_msix_unmask - Unmask the MSIX Vector.
  * @vp: Virtual Path handle.
@@ -2315,22 +2262,6 @@ vxge_hw_vpath_msix_unmask(struct __vxge_hw_vpath_handle *vp, int msix_id)
                        &hldev->common_reg->clear_msix_mask_vect[msix_id%4]);
 }
 
-/**
- * vxge_hw_vpath_msix_mask_all - Mask all MSIX vectors for the vpath.
- * @vp: Virtual Path handle.
- *
- * The function masks all msix interrupt for the given vpath
- *
- */
-void
-vxge_hw_vpath_msix_mask_all(struct __vxge_hw_vpath_handle *vp)
-{
-
-       __vxge_hw_pio_mem_write32_upper(
-               (u32)vxge_bVALn(vxge_mBIT(vp->vpath->vp_id), 0, 32),
-               &vp->vpath->hldev->common_reg->set_msix_mask_all_vect);
-}
-
 /**
  * vxge_hw_vpath_inta_mask_tx_rx - Mask Tx and Rx interrupts.
  * @vp: Virtual Path handle.
index 6fa07d13798e7aef3efec0ace046cd794c169a65..9890d4d596d0d29a5b8083656e416b1c30ca2b74 100644 (file)
@@ -1748,14 +1748,6 @@ vxge_hw_mrpcim_stats_access(
        u32 offset,
        u64 *stat);
 
-enum vxge_hw_status
-vxge_hw_device_xmac_aggr_stats_get(struct __vxge_hw_device *devh, u32 port,
-                                  struct vxge_hw_xmac_aggr_stats *aggr_stats);
-
-enum vxge_hw_status
-vxge_hw_device_xmac_port_stats_get(struct __vxge_hw_device *devh, u32 port,
-                                  struct vxge_hw_xmac_port_stats *port_stats);
-
 enum vxge_hw_status
 vxge_hw_device_xmac_stats_get(struct __vxge_hw_device *devh,
                              struct vxge_hw_xmac_stats *xmac_stats);
@@ -2117,49 +2109,10 @@ struct __vxge_hw_ring_rxd_priv {
 #endif
 };
 
-/* ========================= RING PRIVATE API ============================= */
-u64
-__vxge_hw_ring_first_block_address_get(
-       struct __vxge_hw_ring *ringh);
-
-enum vxge_hw_status
-__vxge_hw_ring_create(
-       struct __vxge_hw_vpath_handle *vpath_handle,
-       struct vxge_hw_ring_attr *attr);
-
-enum vxge_hw_status
-__vxge_hw_ring_abort(
-       struct __vxge_hw_ring *ringh);
-
-enum vxge_hw_status
-__vxge_hw_ring_reset(
-       struct __vxge_hw_ring *ringh);
-
-enum vxge_hw_status
-__vxge_hw_ring_delete(
-       struct __vxge_hw_vpath_handle *vpath_handle);
-
 /* ========================= FIFO PRIVATE API ============================= */
 
 struct vxge_hw_fifo_attr;
 
-enum vxge_hw_status
-__vxge_hw_fifo_create(
-       struct __vxge_hw_vpath_handle *vpath_handle,
-       struct vxge_hw_fifo_attr *attr);
-
-enum vxge_hw_status
-__vxge_hw_fifo_abort(
-       struct __vxge_hw_fifo *fifoh);
-
-enum vxge_hw_status
-__vxge_hw_fifo_reset(
-       struct __vxge_hw_fifo *ringh);
-
-enum vxge_hw_status
-__vxge_hw_fifo_delete(
-       struct __vxge_hw_vpath_handle *vpath_handle);
-
 struct vxge_hw_mempool_cbs {
        void (*item_func_alloc)(
                        struct vxge_hw_mempool *mempoolh,
@@ -2169,10 +2122,6 @@ struct vxge_hw_mempool_cbs {
                        u32                     is_last);
 };
 
-void
-__vxge_hw_mempool_destroy(
-       struct vxge_hw_mempool *mempool);
-
 #define VXGE_HW_VIRTUAL_PATH_HANDLE(vpath)                             \
                ((struct __vxge_hw_vpath_handle *)(vpath)->vpath_handles.next)
 
@@ -2194,62 +2143,11 @@ __vxge_hw_vpath_rts_table_set(
        u64                     data1,
        u64                     data2);
 
-enum vxge_hw_status
-__vxge_hw_vpath_reset(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_sw_reset(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
 enum vxge_hw_status
 __vxge_hw_vpath_enable(
        struct __vxge_hw_device *devh,
        u32                     vp_id);
 
-void
-__vxge_hw_vpath_prc_configure(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_kdfc_configure(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_mac_configure(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_tim_configure(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_initialize(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vp_initialize(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id,
-       struct vxge_hw_vp_config        *config);
-
-void
-__vxge_hw_vp_terminate(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_alarm_process(
-       struct __vxge_hw_virtualpath    *vpath,
-       u32                     skip_alarms);
-
 void vxge_hw_device_intr_enable(
        struct __vxge_hw_device *devh);
 
@@ -2320,11 +2218,6 @@ vxge_hw_vpath_vid_get(
        struct __vxge_hw_vpath_handle *vpath_handle,
        u64                     *vid);
 
-enum vxge_hw_status
-vxge_hw_vpath_vid_get_next(
-       struct __vxge_hw_vpath_handle *vpath_handle,
-       u64                     *vid);
-
 enum vxge_hw_status
 vxge_hw_vpath_vid_delete(
        struct __vxge_hw_vpath_handle *vpath_handle,
@@ -2386,17 +2279,10 @@ vxge_hw_vpath_msix_mask(struct __vxge_hw_vpath_handle *vpath_handle,
 
 void vxge_hw_device_flush_io(struct __vxge_hw_device *devh);
 
-void
-vxge_hw_vpath_msix_clear(struct __vxge_hw_vpath_handle *vpath_handle,
-                        int msix_id);
-
 void
 vxge_hw_vpath_msix_unmask(struct __vxge_hw_vpath_handle *vpath_handle,
                          int msix_id);
 
-void
-vxge_hw_vpath_msix_mask_all(struct __vxge_hw_vpath_handle *vpath_handle);
-
 enum vxge_hw_status vxge_hw_vpath_intr_enable(
                                struct __vxge_hw_vpath_handle *vpath_handle);
 
@@ -2415,12 +2301,6 @@ vxge_hw_channel_msix_mask(struct __vxge_hw_channel *channelh, int msix_id);
 void
 vxge_hw_channel_msix_unmask(struct __vxge_hw_channel *channelh, int msix_id);
 
-enum vxge_hw_status
-vxge_hw_channel_dtr_alloc(struct __vxge_hw_channel *channel, void **dtrh);
-
-void
-vxge_hw_channel_dtr_post(struct __vxge_hw_channel *channel, void *dtrh);
-
 void
 vxge_hw_channel_dtr_try_complete(struct __vxge_hw_channel *channel,
                                 void **dtrh);
@@ -2436,18 +2316,4 @@ vxge_hw_channel_dtr_count(struct __vxge_hw_channel *channel);
 void
 vxge_hw_vpath_tti_ci_set(struct __vxge_hw_device *hldev, u32 vp_id);
 
-/* ========================== PRIVATE API ================================= */
-
-enum vxge_hw_status
-__vxge_hw_device_handle_link_up_ind(struct __vxge_hw_device *hldev);
-
-enum vxge_hw_status
-__vxge_hw_device_handle_link_down_ind(struct __vxge_hw_device *hldev);
-
-enum vxge_hw_status
-__vxge_hw_device_handle_error(
-               struct __vxge_hw_device *hldev,
-               u32 vp_id,
-               enum vxge_hw_event type);
-
 #endif
index 3a779ffba60bca25ac850637e85cd6fd8ab14642..7e8ca75d2dadbcca7869bee745a6e60e2dd8f851 100644 (file)
@@ -88,12 +88,6 @@ struct cn_queue_dev {
        unsigned char name[CN_CBQ_NAMELEN];
 
        struct workqueue_struct *cn_queue;
-       /* Sent to kevent to create cn_queue only when needed */
-       struct work_struct wq_creation;
-       /* Tell if the wq_creation job is pending/completed */
-       atomic_t wq_requested;
-       /* Wait for cn_queue to be created */
-       wait_queue_head_t wq_created;
 
        struct list_head queue_list;
        spinlock_t queue_lock;
@@ -141,8 +135,6 @@ int cn_netlink_send(struct cn_msg *, u32, gfp_t);
 int cn_queue_add_callback(struct cn_queue_dev *dev, char *name, struct cb_id *id, void (*callback)(struct cn_msg *, struct netlink_skb_parms *));
 void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id);
 
-int queue_cn_work(struct cn_callback_entry *cbq, struct work_struct *work);
-
 struct cn_queue_dev *cn_queue_alloc_dev(char *name, struct sock *);
 void cn_queue_free_dev(struct cn_queue_dev *dev);
 
index fcd3dda8632282c1d23882c28f0a1b4d3bb9828f..072652d94d9f5afe908f982c1acce9339bfbfc32 100644 (file)
@@ -585,15 +585,15 @@ static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table,
                table->ents[hash & table->mask] = RPS_NO_CPU;
 }
 
-extern struct rps_sock_flow_table *rps_sock_flow_table;
+extern struct rps_sock_flow_table __rcu *rps_sock_flow_table;
 
 /* This structure contains an instance of an RX queue. */
 struct netdev_rx_queue {
-       struct rps_map *rps_map;
-       struct rps_dev_flow_table *rps_flow_table;
-       struct kobject kobj;
-       struct netdev_rx_queue *first;
-       atomic_t count;
+       struct rps_map __rcu            *rps_map;
+       struct rps_dev_flow_table __rcu *rps_flow_table;
+       struct kobject                  kobj;
+       struct netdev_rx_queue          *first;
+       atomic_t                        count;
 } ____cacheline_aligned_in_smp;
 #endif /* CONFIG_RPS */
 
@@ -944,7 +944,7 @@ struct net_device {
        /* Protocol specific pointers */
 
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
-       struct vlan_group       *vlgrp;         /* VLAN group */
+       struct vlan_group __rcu *vlgrp;         /* VLAN group */
 #endif
 #ifdef CONFIG_NET_DSA
        void                    *dsa_ptr;       /* dsa specific data */
@@ -952,7 +952,7 @@ struct net_device {
        void                    *atalk_ptr;     /* AppleTalk link       */
        struct in_device __rcu  *ip_ptr;        /* IPv4 specific data   */
        void                    *dn_ptr;        /* DECnet specific data */
-       void                    *ip6_ptr;       /* IPv6 specific data */
+       struct inet6_dev __rcu  *ip6_ptr;       /* IPv6 specific data */
        void                    *ec_ptr;        /* Econet specific data */
        void                    *ax25_ptr;      /* AX.25 specific data */
        struct wireless_dev     *ieee80211_ptr; /* IEEE 802.11 specific data,
@@ -1072,7 +1072,7 @@ struct net_device {
                struct pcpu_dstats __percpu     *dstats; /* dummy stats */
        };
        /* GARP */
-       struct garp_port        *garp_port;
+       struct garp_port __rcu  *garp_port;
 
        /* class/net/name entry */
        struct device           dev;
index a6e047a04f798ed1ae0f75583ad7a2430b2c3958..7da5fa845959ab3dc9c2a393d7336a318c113aeb 100644 (file)
@@ -472,11 +472,7 @@ static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
 int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id);
 struct phy_device* get_phy_device(struct mii_bus *bus, int addr);
 int phy_device_register(struct phy_device *phy);
-int phy_clear_interrupt(struct phy_device *phydev);
-int phy_config_interrupt(struct phy_device *phydev, u32 interrupts);
 int phy_init_hw(struct phy_device *phydev);
-int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
-               u32 flags, phy_interface_t interface);
 struct phy_device * phy_attach(struct net_device *dev,
                const char *bus_id, u32 flags, phy_interface_t interface);
 struct phy_device *phy_find_first(struct mii_bus *bus);
@@ -492,17 +488,12 @@ void phy_start(struct phy_device *phydev);
 void phy_stop(struct phy_device *phydev);
 int phy_start_aneg(struct phy_device *phydev);
 
-void phy_sanitize_settings(struct phy_device *phydev);
 int phy_stop_interrupts(struct phy_device *phydev);
-int phy_enable_interrupts(struct phy_device *phydev);
-int phy_disable_interrupts(struct phy_device *phydev);
 
 static inline int phy_read_status(struct phy_device *phydev) {
        return phydev->drv->read_status(phydev);
 }
 
-int genphy_config_advert(struct phy_device *phydev);
-int genphy_setup_forced(struct phy_device *phydev);
 int genphy_restart_aneg(struct phy_device *phydev);
 int genphy_config_aneg(struct phy_device *phydev);
 int genphy_update_link(struct phy_device *phydev);
@@ -511,8 +502,6 @@ int genphy_suspend(struct phy_device *phydev);
 int genphy_resume(struct phy_device *phydev);
 void phy_driver_unregister(struct phy_driver *drv);
 int phy_driver_register(struct phy_driver *new_driver);
-void phy_prepare_link(struct phy_device *phydev,
-               void (*adjust_link)(struct net_device *));
 void phy_state_machine(struct work_struct *work);
 void phy_start_machine(struct phy_device *phydev,
                void (*handler)(struct net_device *));
@@ -523,7 +512,6 @@ int phy_mii_ioctl(struct phy_device *phydev,
                struct ifreq *ifr, int cmd);
 int phy_start_interrupts(struct phy_device *phydev);
 void phy_print_status(struct phy_device *phydev);
-struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id);
 void phy_device_free(struct phy_device *phydev);
 
 int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
index 825f172caba97e607fb3de28d3ba5c4009519419..f4c295984c455782aa9c5512cdc15a3621874937 100644 (file)
@@ -107,7 +107,7 @@ struct garp_applicant {
 };
 
 struct garp_port {
-       struct garp_applicant   *applicants[GARP_APPLICATION_MAX + 1];
+       struct garp_applicant __rcu     *applicants[GARP_APPLICATION_MAX + 1];
 };
 
 extern int     garp_register_application(struct garp_application *app);
index dbee3fe260e13877e28357c2477a66582cd1c03e..86e2b182a0c09eddab243d4b33bd00d03dc89f70 100644 (file)
@@ -59,7 +59,7 @@ struct ipcm_cookie {
 #define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb))
 
 struct ip_ra_chain {
-       struct ip_ra_chain      *next;
+       struct ip_ra_chain __rcu *next;
        struct sock             *sk;
        union {
                void                    (*destructor)(struct sock *);
@@ -68,7 +68,7 @@ struct ip_ra_chain {
        struct rcu_head         rcu;
 };
 
-extern struct ip_ra_chain *ip_ra_chain;
+extern struct ip_ra_chain __rcu *ip_ra_chain;
 
 /* IP flags. */
 #define IP_CE          0x8000          /* Flag: "Congestion"           */
index fc94ec568a50a54db39053b9bdcf0d862c7eba9a..fc73e667b50e4e79d506fa536b9635ac39e787c9 100644 (file)
@@ -13,7 +13,7 @@
 /* IPv6 tunnel */
 
 struct ip6_tnl {
-       struct ip6_tnl *next;   /* next tunnel in list */
+       struct ip6_tnl __rcu *next;     /* next tunnel in list */
        struct net_device *dev; /* virtual device associated with tunnel */
        struct ip6_tnl_parm parms;      /* tunnel configuration parameters */
        struct flowi fl;        /* flowi template for xmit */
index 58abbf966b0c816a3f22d0060fa0ad8aa08113ea..0403fe4c45199e2f5888d44700a9fb3a93df27af 100644 (file)
@@ -16,7 +16,7 @@ struct ip_tunnel_6rd_parm {
 };
 
 struct ip_tunnel {
-       struct ip_tunnel        *next;
+       struct ip_tunnel __rcu  *next;
        struct net_device       *dev;
 
        int                     err_count;      /* Number of arrived ICMP errors */
index 65af9a07cf766b3fe0309149cd46fcc6495aaffb..1bf812b21fb706a8c108c1d2faeb40986f552746 100644 (file)
@@ -88,7 +88,7 @@ struct net {
 #ifdef CONFIG_WEXT_CORE
        struct sk_buff_head     wext_nlevents;
 #endif
-       struct net_generic      *gen;
+       struct net_generic __rcu        *gen;
 
        /* Note : following structs are cache line aligned */
 #ifdef CONFIG_XFRM
index 73a4f9702a65c816c3701ab7fa9777fdbcaa2c72..c7a736228ca2dcab930f7f4a9f07d5fda2858c7c 100644 (file)
@@ -301,7 +301,7 @@ struct sock {
        const struct cred       *sk_peer_cred;
        long                    sk_rcvtimeo;
        long                    sk_sndtimeo;
-       struct sk_filter        *sk_filter;
+       struct sk_filter __rcu  *sk_filter;
        void                    *sk_protinfo;
        struct timer_list       sk_timer;
        ktime_t                 sk_stamp;
index f28d7c9b9f8d4d46978e83060e51dbbcda32bf3b..ffcd47820a5b4266f0206b0c04fd17105a9ad739 100644 (file)
@@ -1272,7 +1272,7 @@ struct xfrm6_tunnel {
        int (*handler)(struct sk_buff *skb);
        int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt,
                           u8 type, u8 code, int offset, __be32 info);
-       struct xfrm6_tunnel *next;
+       struct xfrm6_tunnel __rcu *next;
        int priority;
 };
 
index 941f2a324d3aed7ef68bb2173eb3f562d49a104a..c1df2dad8c6b58470a51d459bd2263989d1d96f4 100644 (file)
@@ -346,8 +346,8 @@ int garp_request_join(const struct net_device *dev,
                      const struct garp_application *appl,
                      const void *data, u8 len, u8 type)
 {
-       struct garp_port *port = dev->garp_port;
-       struct garp_applicant *app = port->applicants[appl->type];
+       struct garp_port *port = rtnl_dereference(dev->garp_port);
+       struct garp_applicant *app = rtnl_dereference(port->applicants[appl->type]);
        struct garp_attr *attr;
 
        spin_lock_bh(&app->lock);
@@ -366,8 +366,8 @@ void garp_request_leave(const struct net_device *dev,
                        const struct garp_application *appl,
                        const void *data, u8 len, u8 type)
 {
-       struct garp_port *port = dev->garp_port;
-       struct garp_applicant *app = port->applicants[appl->type];
+       struct garp_port *port = rtnl_dereference(dev->garp_port);
+       struct garp_applicant *app = rtnl_dereference(port->applicants[appl->type]);
        struct garp_attr *attr;
 
        spin_lock_bh(&app->lock);
@@ -546,11 +546,11 @@ static int garp_init_port(struct net_device *dev)
 
 static void garp_release_port(struct net_device *dev)
 {
-       struct garp_port *port = dev->garp_port;
+       struct garp_port *port = rtnl_dereference(dev->garp_port);
        unsigned int i;
 
        for (i = 0; i <= GARP_APPLICATION_MAX; i++) {
-               if (port->applicants[i])
+               if (rtnl_dereference(port->applicants[i]))
                        return;
        }
        rcu_assign_pointer(dev->garp_port, NULL);
@@ -565,7 +565,7 @@ int garp_init_applicant(struct net_device *dev, struct garp_application *appl)
 
        ASSERT_RTNL();
 
-       if (!dev->garp_port) {
+       if (!rtnl_dereference(dev->garp_port)) {
                err = garp_init_port(dev);
                if (err < 0)
                        goto err1;
@@ -601,8 +601,8 @@ EXPORT_SYMBOL_GPL(garp_init_applicant);
 
 void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl)
 {
-       struct garp_port *port = dev->garp_port;
-       struct garp_applicant *app = port->applicants[appl->type];
+       struct garp_port *port = rtnl_dereference(dev->garp_port);
+       struct garp_applicant *app = rtnl_dereference(port->applicants[appl->type]);
 
        ASSERT_RTNL();
 
index 53c8f77f0ccd1025a7061568b551a1d9631c0dd1..978c30b1b36b5a138eeeb7b9780009686f356d6e 100644 (file)
@@ -21,8 +21,8 @@
 #define GARP_ADDR_MAX  0x2F
 #define GARP_ADDR_RANGE        (GARP_ADDR_MAX - GARP_ADDR_MIN)
 
-static const struct stp_proto *garp_protos[GARP_ADDR_RANGE + 1] __read_mostly;
-static const struct stp_proto *stp_proto __read_mostly;
+static const struct stp_proto __rcu *garp_protos[GARP_ADDR_RANGE + 1] __read_mostly;
+static const struct stp_proto __rcu *stp_proto __read_mostly;
 
 static struct llc_sap *sap __read_mostly;
 static unsigned int sap_registered;
index 05b867e43757dadceaf89d1287b5209a60ca5a65..52077ca22072d6eeab3e12db0030fb5f3c2db68c 100644 (file)
@@ -112,7 +112,7 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
 
        ASSERT_RTNL();
 
-       grp = real_dev->vlgrp;
+       grp = rtnl_dereference(real_dev->vlgrp);
        BUG_ON(!grp);
 
        /* Take it out of our own structures, but be sure to interlock with
@@ -177,7 +177,7 @@ int register_vlan_dev(struct net_device *dev)
        struct vlan_group *grp, *ngrp = NULL;
        int err;
 
-       grp = real_dev->vlgrp;
+       grp = rtnl_dereference(real_dev->vlgrp);
        if (!grp) {
                ngrp = grp = vlan_group_alloc(real_dev);
                if (!grp)
@@ -385,7 +385,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
                dev->netdev_ops->ndo_vlan_rx_add_vid(dev, 0);
        }
 
-       grp = dev->vlgrp;
+       grp = rtnl_dereference(dev->vlgrp);
        if (!grp)
                goto out;
 
index 78b5a89b0f40a455e4229fb04b291e87877b491b..e8a8dc19365b18a3b77ac5eacdaa1ba9568f8aaf 100644 (file)
@@ -2213,7 +2213,7 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
 }
 
 static DEFINE_PER_CPU(int, xmit_recursion);
-#define RECURSION_LIMIT 3
+#define RECURSION_LIMIT 10
 
 /**
  *     dev_queue_xmit - transmit a buffer
@@ -2413,7 +2413,7 @@ EXPORT_SYMBOL(__skb_get_rxhash);
 #ifdef CONFIG_RPS
 
 /* One global table that all flow-based protocols share. */
-struct rps_sock_flow_table *rps_sock_flow_table __read_mostly;
+struct rps_sock_flow_table __rcu *rps_sock_flow_table __read_mostly;
 EXPORT_SYMBOL(rps_sock_flow_table);
 
 /*
@@ -2425,7 +2425,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
                       struct rps_dev_flow **rflowp)
 {
        struct netdev_rx_queue *rxqueue;
-       struct rps_map *map = NULL;
+       struct rps_map *map;
        struct rps_dev_flow_table *flow_table;
        struct rps_sock_flow_table *sock_flow_table;
        int cpu = -1;
@@ -2444,15 +2444,15 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
        } else
                rxqueue = dev->_rx;
 
-       if (rxqueue->rps_map) {
-               map = rcu_dereference(rxqueue->rps_map);
-               if (map && map->len == 1) {
+       map = rcu_dereference(rxqueue->rps_map);
+       if (map) {
+               if (map->len == 1) {
                        tcpu = map->cpus[0];
                        if (cpu_online(tcpu))
                                cpu = tcpu;
                        goto done;
                }
-       } else if (!rxqueue->rps_flow_table) {
+       } else if (!rcu_dereference_raw(rxqueue->rps_flow_table)) {
                goto done;
        }
 
@@ -5416,7 +5416,7 @@ void netdev_run_todo(void)
                /* paranoia */
                BUG_ON(netdev_refcnt_read(dev));
                WARN_ON(rcu_dereference_raw(dev->ip_ptr));
-               WARN_ON(dev->ip6_ptr);
+               WARN_ON(rcu_dereference_raw(dev->ip6_ptr));
                WARN_ON(dev->dn_ptr);
 
                if (dev->destructor)
index 7adf50352918713af197b55283faf6b105087f4e..7beaec36b541274bcd1d62c9fe8376b368ab3386 100644 (file)
@@ -89,8 +89,8 @@ int sk_filter(struct sock *sk, struct sk_buff *skb)
        rcu_read_lock_bh();
        filter = rcu_dereference_bh(sk->sk_filter);
        if (filter) {
-               unsigned int pkt_len = sk_run_filter(skb, filter->insns,
-                               filter->len);
+               unsigned int pkt_len = sk_run_filter(skb, filter->insns, filter->len);
+
                err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM;
        }
        rcu_read_unlock_bh();
index b143173e3eb2bd9259e1c0122800848146b4c136..a5ff5a89f376bb1299dec78fa34abe9480ae01f1 100644 (file)
@@ -598,7 +598,8 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
        }
 
        spin_lock(&rps_map_lock);
-       old_map = queue->rps_map;
+       old_map = rcu_dereference_protected(queue->rps_map,
+                                           lockdep_is_held(&rps_map_lock));
        rcu_assign_pointer(queue->rps_map, map);
        spin_unlock(&rps_map_lock);
 
@@ -677,7 +678,8 @@ static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue,
                table = NULL;
 
        spin_lock(&rps_dev_flow_lock);
-       old_table = queue->rps_flow_table;
+       old_table = rcu_dereference_protected(queue->rps_flow_table,
+                                             lockdep_is_held(&rps_dev_flow_lock));
        rcu_assign_pointer(queue->rps_flow_table, table);
        spin_unlock(&rps_dev_flow_lock);
 
@@ -705,13 +707,17 @@ static void rx_queue_release(struct kobject *kobj)
 {
        struct netdev_rx_queue *queue = to_rx_queue(kobj);
        struct netdev_rx_queue *first = queue->first;
+       struct rps_map *map;
+       struct rps_dev_flow_table *flow_table;
 
-       if (queue->rps_map)
-               call_rcu(&queue->rps_map->rcu, rps_map_release);
 
-       if (queue->rps_flow_table)
-               call_rcu(&queue->rps_flow_table->rcu,
-                   rps_dev_flow_table_release);
+       map = rcu_dereference_raw(queue->rps_map);
+       if (map)
+               call_rcu(&map->rcu, rps_map_release);
+
+       flow_table = rcu_dereference_raw(queue->rps_flow_table);
+       if (flow_table)
+               call_rcu(&flow_table->rcu, rps_dev_flow_table_release);
 
        if (atomic_dec_and_test(&first->count))
                kfree(first);
index c988e685433acad2bb471097d79ec024509cee9d..3f860261c5eea2be402ed0556a3a8b3f6fd7fc9b 100644 (file)
@@ -42,7 +42,9 @@ static int net_assign_generic(struct net *net, int id, void *data)
        BUG_ON(!mutex_is_locked(&net_mutex));
        BUG_ON(id == 0);
 
-       ng = old_ng = net->gen;
+       old_ng = rcu_dereference_protected(net->gen,
+                                          lockdep_is_held(&net_mutex));
+       ng = old_ng;
        if (old_ng->len >= id)
                goto assign;
 
index 2c0df0f95b3d488c8e6f8818857f19c02726e200..679b797d06b1028888bdc9590a1f741918eece6c 100644 (file)
@@ -771,10 +771,10 @@ done:
 static unsigned long num_arg(const char __user * user_buffer,
                             unsigned long maxlen, unsigned long *num)
 {
-       int i = 0;
+       int i;
        *num = 0;
 
-       for (; i < maxlen; i++) {
+       for (i = 0; i < maxlen; i++) {
                char c;
                if (get_user(c, &user_buffer[i]))
                        return -EFAULT;
@@ -789,9 +789,9 @@ static unsigned long num_arg(const char __user * user_buffer,
 
 static int strn_len(const char __user * user_buffer, unsigned int maxlen)
 {
-       int i = 0;
+       int i;
 
-       for (; i < maxlen; i++) {
+       for (i = 0; i < maxlen; i++) {
                char c;
                if (get_user(c, &user_buffer[i]))
                        return -EFAULT;
@@ -846,7 +846,7 @@ static ssize_t pktgen_if_write(struct file *file,
 {
        struct seq_file *seq = file->private_data;
        struct pktgen_dev *pkt_dev = seq->private;
-       int i = 0, max, len;
+       int i, max, len;
        char name[16], valstr[32];
        unsigned long value = 0;
        char *pg_result = NULL;
@@ -860,13 +860,13 @@ static ssize_t pktgen_if_write(struct file *file,
                return -EINVAL;
        }
 
-       max = count - i;
-       tmp = count_trail_chars(&user_buffer[i], max);
+       max = count;
+       tmp = count_trail_chars(user_buffer, max);
        if (tmp < 0) {
                pr_warning("illegal format\n");
                return tmp;
        }
-       i += tmp;
+       i = tmp;
 
        /* Read variable name */
 
@@ -1764,7 +1764,7 @@ static ssize_t pktgen_thread_write(struct file *file,
 {
        struct seq_file *seq = file->private_data;
        struct pktgen_thread *t = seq->private;
-       int i = 0, max, len, ret;
+       int i, max, len, ret;
        char name[40];
        char *pg_result;
 
@@ -1773,12 +1773,12 @@ static ssize_t pktgen_thread_write(struct file *file,
                return -EINVAL;
        }
 
-       max = count - i;
-       len = count_trail_chars(&user_buffer[i], max);
+       max = count;
+       len = count_trail_chars(user_buffer, max);
        if (len < 0)
                return len;
 
-       i += len;
+       i = len;
 
        /* Read variable name */
 
@@ -1975,7 +1975,7 @@ static struct net_device *pktgen_dev_get_by_name(struct pktgen_dev *pkt_dev,
                                                 const char *ifname)
 {
        char b[IFNAMSIZ+5];
-       int i = 0;
+       int i;
 
        for (i = 0; ifname[i] != '@'; i++) {
                if (i == IFNAMSIZ)
@@ -2519,8 +2519,8 @@ static void free_SAs(struct pktgen_dev *pkt_dev)
 {
        if (pkt_dev->cflows) {
                /* let go of the SAs if we have them */
-               int i = 0;
-               for ( i < pkt_dev->cflows; i++) {
+               int i;
+               for (i = 0; i < pkt_dev->cflows; i++) {
                        struct xfrm_state *x = pkt_dev->flows[i].x;
                        if (x) {
                                xfrm_state_put(x);
index 11db43632df8712576b4ff8f6c8eed7a8fdfd21d..3eed5424e659a1ab130324d16bfe3c0af4ab2feb 100644 (file)
@@ -1225,7 +1225,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
                sock_reset_flag(newsk, SOCK_DONE);
                skb_queue_head_init(&newsk->sk_error_queue);
 
-               filter = newsk->sk_filter;
+               filter = rcu_dereference_protected(newsk->sk_filter, 1);
                if (filter != NULL)
                        sk_filter_charge(newsk, filter);
 
index 01eee5d984be4b6d838357a56e0211508d0e31ba..385b6095fdc4b1da8540c879d3a5c450954cb7f7 100644 (file)
@@ -34,7 +34,8 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
 
        mutex_lock(&sock_flow_mutex);
 
-       orig_sock_table = rps_sock_flow_table;
+       orig_sock_table = rcu_dereference_protected(rps_sock_flow_table,
+                                       lockdep_is_held(&sock_flow_mutex));
        size = orig_size = orig_sock_table ? orig_sock_table->mask + 1 : 0;
 
        ret = proc_dointvec(&tmp, write, buffer, lenp, ppos);
index caea6885fdbd0810ea3e8d9eeefd5f74282a0930..c6933f2ea3105be192c7eaa1ac06045539cd07cc 100644 (file)
@@ -22,7 +22,7 @@
 #include <net/gre.h>
 
 
-static const struct gre_protocol *gre_proto[GREPROTO_MAX] __read_mostly;
+static const struct gre_protocol __rcu *gre_proto[GREPROTO_MAX] __read_mostly;
 static DEFINE_SPINLOCK(gre_proto_lock);
 
 int gre_add_protocol(const struct gre_protocol *proto, u8 version)
@@ -51,7 +51,8 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version)
                goto err_out;
 
        spin_lock(&gre_proto_lock);
-       if (gre_proto[version] != proto)
+       if (rcu_dereference_protected(gre_proto[version],
+                       lockdep_is_held(&gre_proto_lock)) != proto)
                goto err_out_unlock;
        rcu_assign_pointer(gre_proto[version], NULL);
        spin_unlock(&gre_proto_lock);
index 64b70ad162e370dbeb5b60adda5dd811182fc0f5..3948c86e59ca697645a3316145fca66db5096880 100644 (file)
@@ -238,7 +238,7 @@ int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc)
    but receiver should be enough clever f.e. to forward mtrace requests,
    sent to multicast group to reach destination designated router.
  */
-struct ip_ra_chain *ip_ra_chain;
+struct ip_ra_chain __rcu *ip_ra_chain;
 static DEFINE_SPINLOCK(ip_ra_lock);
 
 
@@ -253,7 +253,8 @@ static void ip_ra_destroy_rcu(struct rcu_head *head)
 int ip_ra_control(struct sock *sk, unsigned char on,
                  void (*destructor)(struct sock *))
 {
-       struct ip_ra_chain *ra, *new_ra, **rap;
+       struct ip_ra_chain *ra, *new_ra;
+       struct ip_ra_chain __rcu **rap;
 
        if (sk->sk_type != SOCK_RAW || inet_sk(sk)->inet_num == IPPROTO_RAW)
                return -EINVAL;
@@ -261,7 +262,10 @@ int ip_ra_control(struct sock *sk, unsigned char on,
        new_ra = on ? kmalloc(sizeof(*new_ra), GFP_KERNEL) : NULL;
 
        spin_lock_bh(&ip_ra_lock);
-       for (rap = &ip_ra_chain; (ra = *rap) != NULL; rap = &ra->next) {
+       for (rap = &ip_ra_chain;
+            (ra = rcu_dereference_protected(*rap,
+                       lockdep_is_held(&ip_ra_lock))) != NULL;
+            rap = &ra->next) {
                if (ra->sk == sk) {
                        if (on) {
                                spin_unlock_bh(&ip_ra_lock);
index b3f7e8cf18ac4227d298c7d4d659a7d19c50a244..28cb2d733a3cf6a9dd8e65a8dd2de0b44caae782 100644 (file)
@@ -1413,7 +1413,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
                }
        }
 
-       if (sk->sk_filter) {
+       if (rcu_dereference_raw(sk->sk_filter)) {
                if (udp_lib_checksum_complete(skb))
                        goto drop;
        }
index c2c0f89397b1164bacefdb449cd2b97dbe41d66c..38b9a56c173f54f7861a07483446a1e45dcf598a 100644 (file)
@@ -1371,6 +1371,7 @@ static void ip6_tnl_dev_setup(struct net_device *dev)
        dev->flags |= IFF_NOARP;
        dev->addr_len = sizeof(struct in6_addr);
        dev->features |= NETIF_F_NETNS_LOCAL;
+       dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
 }
 
 
index 0553867a317f4466b31df3bd6d2695e180537be9..d1770e061c081de2bed4ad23932ff07291e11a90 100644 (file)
@@ -343,6 +343,10 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
                break;
 
        case IPV6_TRANSPARENT:
+               if (!capable(CAP_NET_ADMIN)) {
+                       retv = -EPERM;
+                       break;
+               }
                if (optlen < sizeof(int))
                        goto e_inval;
                /* we don't have a separate transparent bit for IPV6 we use the one in the IPv4 socket */
index 44d2eeac089b4fedc3a65c312263b667231838dc..448464844a253474fed5624f75c68c9bb33cd98e 100644 (file)
@@ -5,10 +5,15 @@
 menu "IPv6: Netfilter Configuration"
        depends on INET && IPV6 && NETFILTER
 
+config NF_DEFRAG_IPV6
+       tristate
+       default n
+
 config NF_CONNTRACK_IPV6
        tristate "IPv6 connection tracking support"
        depends on INET && IPV6 && NF_CONNTRACK
        default m if NETFILTER_ADVANCED=n
+       select NF_DEFRAG_IPV6
        ---help---
          Connection tracking keeps a record of what packets have passed
          through your machine, in order to figure out how they are related
index 3f8e4a3d83ce107bdf2280c35fac189f8a2a2838..0a432c9b079556e13d5eb58e70446cd09c72ec22 100644 (file)
@@ -12,11 +12,14 @@ obj-$(CONFIG_IP6_NF_SECURITY) += ip6table_security.o
 
 # objects for l3 independent conntrack
 nf_conntrack_ipv6-objs  :=  nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o
-nf_defrag_ipv6-objs := nf_defrag_ipv6_hooks.o nf_conntrack_reasm.o
 
 # l3 independent conntrack
 obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o nf_defrag_ipv6.o
 
+# defrag
+nf_defrag_ipv6-objs := nf_defrag_ipv6_hooks.o nf_conntrack_reasm.o
+obj-$(CONFIG_NF_DEFRAG_IPV6) += nf_defrag_ipv6.o
+
 # matches
 obj-$(CONFIG_IP6_NF_MATCH_AH) += ip6t_ah.o
 obj-$(CONFIG_IP6_NF_MATCH_EUI64) += ip6t_eui64.o
index 489d71b844ac9ba7c85d7f5612922e4ceeb712cc..3a3f129a44cb3561dd3e135164626f8352c565b7 100644 (file)
@@ -625,21 +625,24 @@ int nf_ct_frag6_init(void)
        inet_frags_init_net(&nf_init_frags);
        inet_frags_init(&nf_frags);
 
+#ifdef CONFIG_SYSCTL
        nf_ct_frag6_sysctl_header = register_sysctl_paths(nf_net_netfilter_sysctl_path,
                                                          nf_ct_frag6_sysctl_table);
        if (!nf_ct_frag6_sysctl_header) {
                inet_frags_fini(&nf_frags);
                return -ENOMEM;
        }
+#endif
 
        return 0;
 }
 
 void nf_ct_frag6_cleanup(void)
 {
+#ifdef CONFIG_SYSCTL
        unregister_sysctl_table(nf_ct_frag6_sysctl_header);
        nf_ct_frag6_sysctl_header = NULL;
-
+#endif
        inet_frags_fini(&nf_frags);
 
        nf_init_frags.low_thresh = 0;
index 45e6efb7f17120554bb963d983d74028a2001342..86c39526ba5ecb581e197d245855c9edabb53e99 100644 (file)
@@ -373,7 +373,7 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr,
 
 static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
 {
-       if ((raw6_sk(sk)->checksum || sk->sk_filter) &&
+       if ((raw6_sk(sk)->checksum || rcu_dereference_raw(sk->sk_filter)) &&
            skb_checksum_complete(skb)) {
                atomic_inc(&sk->sk_drops);
                kfree_skb(skb);
index d9864725d0c6a259ba8a4d35cbe08762de5e53f4..4f3cec12aa8575a860f18124f0f4ee7f83cf540d 100644 (file)
 #include <net/protocol.h>
 #include <net/xfrm.h>
 
-static struct xfrm6_tunnel *tunnel6_handlers __read_mostly;
-static struct xfrm6_tunnel *tunnel46_handlers __read_mostly;
+static struct xfrm6_tunnel __rcu *tunnel6_handlers __read_mostly;
+static struct xfrm6_tunnel __rcu *tunnel46_handlers __read_mostly;
 static DEFINE_MUTEX(tunnel6_mutex);
 
 int xfrm6_tunnel_register(struct xfrm6_tunnel *handler, unsigned short family)
 {
-       struct xfrm6_tunnel **pprev;
+       struct xfrm6_tunnel __rcu **pprev;
+       struct xfrm6_tunnel *t;
        int ret = -EEXIST;
        int priority = handler->priority;
 
        mutex_lock(&tunnel6_mutex);
 
        for (pprev = (family == AF_INET6) ? &tunnel6_handlers : &tunnel46_handlers;
-            *pprev; pprev = &(*pprev)->next) {
-               if ((*pprev)->priority > priority)
+            (t = rcu_dereference_protected(*pprev,
+                       lockdep_is_held(&tunnel6_mutex))) != NULL;
+            pprev = &t->next) {
+               if (t->priority > priority)
                        break;
-               if ((*pprev)->priority == priority)
+               if (t->priority == priority)
                        goto err;
        }
 
@@ -65,14 +68,17 @@ EXPORT_SYMBOL(xfrm6_tunnel_register);
 
 int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family)
 {
-       struct xfrm6_tunnel **pprev;
+       struct xfrm6_tunnel __rcu **pprev;
+       struct xfrm6_tunnel *t;
        int ret = -ENOENT;
 
        mutex_lock(&tunnel6_mutex);
 
        for (pprev = (family == AF_INET6) ? &tunnel6_handlers : &tunnel46_handlers;
-            *pprev; pprev = &(*pprev)->next) {
-               if (*pprev == handler) {
+            (t = rcu_dereference_protected(*pprev,
+                       lockdep_is_held(&tunnel6_mutex))) != NULL;
+            pprev = &t->next) {
+               if (t == handler) {
                        *pprev = handler->next;
                        ret = 0;
                        break;
index c84dad432114ef0d885b29244bf9df0854f750e2..91def93bec85060e7571218c20439cabd4ec824f 100644 (file)
@@ -527,7 +527,7 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
                }
        }
 
-       if (sk->sk_filter) {
+       if (rcu_dereference_raw(sk->sk_filter)) {
                if (udp_lib_checksum_complete(skb))
                        goto drop;
        }
index 1712af1c7b3f7868146d9d5ace84937aaa87f745..c64ce0a0bb03b11c3b28d3445d2abb361fee9070 100644 (file)
@@ -111,6 +111,10 @@ struct l2tp_net {
        spinlock_t l2tp_session_hlist_lock;
 };
 
+static void l2tp_session_set_header_len(struct l2tp_session *session, int version);
+static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel);
+static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel);
+
 static inline struct l2tp_net *l2tp_pernet(struct net *net)
 {
        BUG_ON(!net);
@@ -118,6 +122,34 @@ static inline struct l2tp_net *l2tp_pernet(struct net *net)
        return net_generic(net, l2tp_net_id);
 }
 
+
+/* Tunnel reference counts. Incremented per session that is added to
+ * the tunnel.
+ */
+static inline void l2tp_tunnel_inc_refcount_1(struct l2tp_tunnel *tunnel)
+{
+       atomic_inc(&tunnel->ref_count);
+}
+
+static inline void l2tp_tunnel_dec_refcount_1(struct l2tp_tunnel *tunnel)
+{
+       if (atomic_dec_and_test(&tunnel->ref_count))
+               l2tp_tunnel_free(tunnel);
+}
+#ifdef L2TP_REFCNT_DEBUG
+#define l2tp_tunnel_inc_refcount(_t) do { \
+               printk(KERN_DEBUG "l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \
+               l2tp_tunnel_inc_refcount_1(_t);                         \
+       } while (0)
+#define l2tp_tunnel_dec_refcount(_t) do { \
+               printk(KERN_DEBUG "l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \
+               l2tp_tunnel_dec_refcount_1(_t);                         \
+       } while (0)
+#else
+#define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t)
+#define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t)
+#endif
+
 /* Session hash global list for L2TPv3.
  * The session_id SHOULD be random according to RFC3931, but several
  * L2TP implementations use incrementing session_ids.  So we do a real
@@ -699,8 +731,8 @@ EXPORT_SYMBOL(l2tp_recv_common);
  * Returns 1 if the packet was not a good data packet and could not be
  * forwarded.  All such packets are passed up to userspace to deal with.
  */
-int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
-                      int (*payload_hook)(struct sk_buff *skb))
+static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
+                             int (*payload_hook)(struct sk_buff *skb))
 {
        struct l2tp_session *session = NULL;
        unsigned char *ptr, *optr;
@@ -812,7 +844,6 @@ error:
 
        return 1;
 }
-EXPORT_SYMBOL_GPL(l2tp_udp_recv_core);
 
 /* UDP encapsulation receive handler. See net/ipv4/udp.c.
  * Return codes:
@@ -922,7 +953,8 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf)
        return bufp - optr;
 }
 
-int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, size_t data_len)
+static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
+                         size_t data_len)
 {
        struct l2tp_tunnel *tunnel = session->tunnel;
        unsigned int len = skb->len;
@@ -970,7 +1002,6 @@ int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, size_t dat
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(l2tp_xmit_core);
 
 /* Automatically called when the skb is freed.
  */
@@ -1089,7 +1120,7 @@ EXPORT_SYMBOL_GPL(l2tp_xmit_skb);
  * The tunnel context is deleted only when all session sockets have been
  * closed.
  */
-void l2tp_tunnel_destruct(struct sock *sk)
+static void l2tp_tunnel_destruct(struct sock *sk)
 {
        struct l2tp_tunnel *tunnel;
 
@@ -1128,11 +1159,10 @@ void l2tp_tunnel_destruct(struct sock *sk)
 end:
        return;
 }
-EXPORT_SYMBOL(l2tp_tunnel_destruct);
 
 /* When the tunnel is closed, all the attached sessions need to go too.
  */
-void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
+static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
 {
        int hash;
        struct hlist_node *walk;
@@ -1193,12 +1223,11 @@ again:
        }
        write_unlock_bh(&tunnel->hlist_lock);
 }
-EXPORT_SYMBOL_GPL(l2tp_tunnel_closeall);
 
 /* Really kill the tunnel.
  * Come here only when all sessions have been cleared from the tunnel.
  */
-void l2tp_tunnel_free(struct l2tp_tunnel *tunnel)
+static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel)
 {
        struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net);
 
@@ -1217,7 +1246,6 @@ void l2tp_tunnel_free(struct l2tp_tunnel *tunnel)
        atomic_dec(&l2tp_tunnel_count);
        kfree(tunnel);
 }
-EXPORT_SYMBOL_GPL(l2tp_tunnel_free);
 
 /* Create a socket for the tunnel, if one isn't set up by
  * userspace. This is used for static tunnels where there is no
@@ -1512,7 +1540,7 @@ EXPORT_SYMBOL_GPL(l2tp_session_delete);
 /* We come here whenever a session's send_seq, cookie_len or
  * l2specific_len parameters are set.
  */
-void l2tp_session_set_header_len(struct l2tp_session *session, int version)
+static void l2tp_session_set_header_len(struct l2tp_session *session, int version)
 {
        if (version == L2TP_HDR_VER_2) {
                session->hdr_len = 6;
@@ -1525,7 +1553,6 @@ void l2tp_session_set_header_len(struct l2tp_session *session, int version)
        }
 
 }
-EXPORT_SYMBOL_GPL(l2tp_session_set_header_len);
 
 struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunnel, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg)
 {
index f0f318edd3f19280f863e2db279663fadb02d968..a16a48e79fab09c84a6825baed089e1a35216b37 100644 (file)
@@ -231,48 +231,15 @@ extern int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_i
 extern int l2tp_tunnel_delete(struct l2tp_tunnel *tunnel);
 extern struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunnel, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg);
 extern int l2tp_session_delete(struct l2tp_session *session);
-extern void l2tp_tunnel_free(struct l2tp_tunnel *tunnel);
 extern void l2tp_session_free(struct l2tp_session *session);
 extern void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, unsigned char *ptr, unsigned char *optr, u16 hdrflags, int length, int (*payload_hook)(struct sk_buff *skb));
-extern int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, int (*payload_hook)(struct sk_buff *skb));
 extern int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb);
 
-extern int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, size_t data_len);
 extern int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len);
-extern void l2tp_tunnel_destruct(struct sock *sk);
-extern void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel);
-extern void l2tp_session_set_header_len(struct l2tp_session *session, int version);
 
 extern int l2tp_nl_register_ops(enum l2tp_pwtype pw_type, const struct l2tp_nl_cmd_ops *ops);
 extern void l2tp_nl_unregister_ops(enum l2tp_pwtype pw_type);
 
-/* Tunnel reference counts. Incremented per session that is added to
- * the tunnel.
- */
-static inline void l2tp_tunnel_inc_refcount_1(struct l2tp_tunnel *tunnel)
-{
-       atomic_inc(&tunnel->ref_count);
-}
-
-static inline void l2tp_tunnel_dec_refcount_1(struct l2tp_tunnel *tunnel)
-{
-       if (atomic_dec_and_test(&tunnel->ref_count))
-               l2tp_tunnel_free(tunnel);
-}
-#ifdef L2TP_REFCNT_DEBUG
-#define l2tp_tunnel_inc_refcount(_t) do { \
-               printk(KERN_DEBUG "l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \
-               l2tp_tunnel_inc_refcount_1(_t);                         \
-       } while (0)
-#define l2tp_tunnel_dec_refcount(_t) do { \
-               printk(KERN_DEBUG "l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \
-               l2tp_tunnel_dec_refcount_1(_t);                         \
-       } while (0)
-#else
-#define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t)
-#define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t)
-#endif
-
 /* Session reference counts. Incremented when code obtains a reference
  * to a session.
  */
index 1c770c0644d1a3111eddbac4463ecd8bd4821850..0bf6a59545ab9439f3ab7126539cd9aef419b752 100644 (file)
@@ -576,7 +576,7 @@ out:
        return copied;
 }
 
-struct proto l2tp_ip_prot = {
+static struct proto l2tp_ip_prot = {
        .name              = "L2TP/IP",
        .owner             = THIS_MODULE,
        .init              = l2tp_ip_open,
index 43288259f4a145d31374a2c0d629ba3b0d16db0e..1534f2b44cafbf8d465d55229f3ee807cf5f6fb2 100644 (file)
@@ -525,6 +525,7 @@ config NETFILTER_XT_TARGET_TPROXY
        depends on NETFILTER_XTABLES
        depends on NETFILTER_ADVANCED
        select NF_DEFRAG_IPV4
+       select NF_DEFRAG_IPV6 if IP6_NF_IPTABLES
        help
          This option adds a `TPROXY' target, which is somewhat similar to
          REDIRECT.  It can only be used in the mangle table and is useful
@@ -927,6 +928,7 @@ config NETFILTER_XT_MATCH_SOCKET
        depends on NETFILTER_ADVANCED
        depends on !NF_CONNTRACK || NF_CONNTRACK
        select NF_DEFRAG_IPV4
+       select NF_DEFRAG_IPV6 if IP6_NF_IPTABLES
        help
          This option adds a `socket' match, which can be used to match
          packets for which a TCP or UDP socket lookup finds a valid socket.
index 19c482caf30b7f1587f41cd7b3c26a3d598bc084..640678f47a2ad5420a869e4fbcd63bd677297c2c 100644 (file)
@@ -21,7 +21,9 @@
 #include <linux/netfilter_ipv4/ip_tables.h>
 
 #include <net/netfilter/ipv4/nf_defrag_ipv4.h>
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+
+#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
+#define XT_TPROXY_HAVE_IPV6 1
 #include <net/if_inet6.h>
 #include <net/addrconf.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
@@ -172,7 +174,7 @@ tproxy_tg4_v1(struct sk_buff *skb, const struct xt_action_param *par)
        return tproxy_tg4(skb, tgi->laddr.ip, tgi->lport, tgi->mark_mask, tgi->mark_value);
 }
 
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+#ifdef XT_TPROXY_HAVE_IPV6
 
 static inline const struct in6_addr *
 tproxy_laddr6(struct sk_buff *skb, const struct in6_addr *user_laddr,
@@ -372,7 +374,7 @@ static struct xt_target tproxy_tg_reg[] __read_mostly = {
                .hooks          = 1 << NF_INET_PRE_ROUTING,
                .me             = THIS_MODULE,
        },
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+#ifdef XT_TPROXY_HAVE_IPV6
        {
                .name           = "TPROXY",
                .family         = NFPROTO_IPV6,
@@ -391,7 +393,7 @@ static struct xt_target tproxy_tg_reg[] __read_mostly = {
 static int __init tproxy_tg_init(void)
 {
        nf_defrag_ipv4_enable();
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+#ifdef XT_TPROXY_HAVE_IPV6
        nf_defrag_ipv6_enable();
 #endif
 
index 2dbd4c857735abdddde389dd5154bbba0e5f2aef..d94a858dc52a1960f33fd7c1243c04a3428bb110 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/skbuff.h>
 #include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
-#include <linux/netfilter_ipv6/ip6_tables.h>
 #include <net/tcp.h>
 #include <net/udp.h>
 #include <net/icmp.h>
 #include <net/inet_sock.h>
 #include <net/netfilter/nf_tproxy_core.h>
 #include <net/netfilter/ipv4/nf_defrag_ipv4.h>
+
+#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
+#define XT_SOCKET_HAVE_IPV6 1
+#include <linux/netfilter_ipv6/ip6_tables.h>
 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
+#endif
 
 #include <linux/netfilter/xt_socket.h>
 
@@ -186,7 +190,7 @@ socket_mt4_v1(const struct sk_buff *skb, struct xt_action_param *par)
        return socket_match(skb, par, par->matchinfo);
 }
 
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+#ifdef XT_SOCKET_HAVE_IPV6
 
 static int
 extract_icmp6_fields(const struct sk_buff *skb,
@@ -331,7 +335,7 @@ static struct xt_match socket_mt_reg[] __read_mostly = {
                                  (1 << NF_INET_LOCAL_IN),
                .me             = THIS_MODULE,
        },
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+#ifdef XT_SOCKET_HAVE_IPV6
        {
                .name           = "socket",
                .revision       = 1,
@@ -348,7 +352,7 @@ static struct xt_match socket_mt_reg[] __read_mostly = {
 static int __init socket_mt_init(void)
 {
        nf_defrag_ipv4_enable();
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+#ifdef XT_SOCKET_HAVE_IPV6
        nf_defrag_ipv6_enable();
 #endif
 
index cd96ed3ccee4602a9fee20464e4a54d3fb0783b2..478181d53c555dc0d7cf9a18714aa0a08b03f3e1 100644 (file)
@@ -83,9 +83,9 @@ struct netlink_sock {
        struct module           *module;
 };
 
-struct listeners_rcu_head {
-       struct rcu_head rcu_head;
-       void *ptr;
+struct listeners {
+       struct rcu_head         rcu;
+       unsigned long           masks[0];
 };
 
 #define NETLINK_KERNEL_SOCKET  0x1
@@ -119,7 +119,7 @@ struct nl_pid_hash {
 struct netlink_table {
        struct nl_pid_hash hash;
        struct hlist_head mc_list;
-       unsigned long *listeners;
+       struct listeners __rcu *listeners;
        unsigned int nl_nonroot;
        unsigned int groups;
        struct mutex *cb_mutex;
@@ -338,7 +338,7 @@ netlink_update_listeners(struct sock *sk)
                        if (i < NLGRPLONGS(nlk_sk(sk)->ngroups))
                                mask |= nlk_sk(sk)->groups[i];
                }
-               tbl->listeners[i] = mask;
+               tbl->listeners->masks[i] = mask;
        }
        /* this function is only called with the netlink table "grabbed", which
         * makes sure updates are visible before bind or setsockopt return. */
@@ -936,7 +936,7 @@ EXPORT_SYMBOL(netlink_unicast);
 int netlink_has_listeners(struct sock *sk, unsigned int group)
 {
        int res = 0;
-       unsigned long *listeners;
+       struct listeners *listeners;
 
        BUG_ON(!netlink_is_kernel(sk));
 
@@ -944,7 +944,7 @@ int netlink_has_listeners(struct sock *sk, unsigned int group)
        listeners = rcu_dereference(nl_table[sk->sk_protocol].listeners);
 
        if (group - 1 < nl_table[sk->sk_protocol].groups)
-               res = test_bit(group - 1, listeners);
+               res = test_bit(group - 1, listeners->masks);
 
        rcu_read_unlock();
 
@@ -1498,7 +1498,7 @@ netlink_kernel_create(struct net *net, int unit, unsigned int groups,
        struct socket *sock;
        struct sock *sk;
        struct netlink_sock *nlk;
-       unsigned long *listeners = NULL;
+       struct listeners *listeners = NULL;
 
        BUG_ON(!nl_table);
 
@@ -1523,8 +1523,7 @@ netlink_kernel_create(struct net *net, int unit, unsigned int groups,
        if (groups < 32)
                groups = 32;
 
-       listeners = kzalloc(NLGRPSZ(groups) + sizeof(struct listeners_rcu_head),
-                           GFP_KERNEL);
+       listeners = kzalloc(sizeof(*listeners) + NLGRPSZ(groups), GFP_KERNEL);
        if (!listeners)
                goto out_sock_release;
 
@@ -1541,7 +1540,7 @@ netlink_kernel_create(struct net *net, int unit, unsigned int groups,
        netlink_table_grab();
        if (!nl_table[unit].registered) {
                nl_table[unit].groups = groups;
-               nl_table[unit].listeners = listeners;
+               rcu_assign_pointer(nl_table[unit].listeners, listeners);
                nl_table[unit].cb_mutex = cb_mutex;
                nl_table[unit].module = module;
                nl_table[unit].registered = 1;
@@ -1572,43 +1571,28 @@ netlink_kernel_release(struct sock *sk)
 EXPORT_SYMBOL(netlink_kernel_release);
 
 
-static void netlink_free_old_listeners(struct rcu_head *rcu_head)
+static void listeners_free_rcu(struct rcu_head *head)
 {
-       struct listeners_rcu_head *lrh;
-
-       lrh = container_of(rcu_head, struct listeners_rcu_head, rcu_head);
-       kfree(lrh->ptr);
+       kfree(container_of(head, struct listeners, rcu));
 }
 
 int __netlink_change_ngroups(struct sock *sk, unsigned int groups)
 {
-       unsigned long *listeners, *old = NULL;
-       struct listeners_rcu_head *old_rcu_head;
+       struct listeners *new, *old;
        struct netlink_table *tbl = &nl_table[sk->sk_protocol];
 
        if (groups < 32)
                groups = 32;
 
        if (NLGRPSZ(tbl->groups) < NLGRPSZ(groups)) {
-               listeners = kzalloc(NLGRPSZ(groups) +
-                                   sizeof(struct listeners_rcu_head),
-                                   GFP_ATOMIC);
-               if (!listeners)
+               new = kzalloc(sizeof(*new) + NLGRPSZ(groups), GFP_ATOMIC);
+               if (!new)
                        return -ENOMEM;
-               old = tbl->listeners;
-               memcpy(listeners, old, NLGRPSZ(tbl->groups));
-               rcu_assign_pointer(tbl->listeners, listeners);
-               /*
-                * Free the old memory after an RCU grace period so we
-                * don't leak it. We use call_rcu() here in order to be
-                * able to call this function from atomic contexts. The
-                * allocation of this memory will have reserved enough
-                * space for struct listeners_rcu_head at the end.
-                */
-               old_rcu_head = (void *)(tbl->listeners +
-                                       NLGRPLONGS(tbl->groups));
-               old_rcu_head->ptr = old;
-               call_rcu(&old_rcu_head->rcu_head, netlink_free_old_listeners);
+               old = rcu_dereference_raw(tbl->listeners);
+               memcpy(new->masks, old->masks, NLGRPSZ(tbl->groups));
+               rcu_assign_pointer(tbl->listeners, new);
+
+               call_rcu(&old->rcu, listeners_free_rcu);
        }
        tbl->groups = groups;
 
@@ -2104,18 +2088,17 @@ static void __net_exit netlink_net_exit(struct net *net)
 
 static void __init netlink_add_usersock_entry(void)
 {
-       unsigned long *listeners;
+       struct listeners *listeners;
        int groups = 32;
 
-       listeners = kzalloc(NLGRPSZ(groups) + sizeof(struct listeners_rcu_head),
-                           GFP_KERNEL);
+       listeners = kzalloc(sizeof(*listeners) + NLGRPSZ(groups), GFP_KERNEL);
        if (!listeners)
-               panic("netlink_add_usersock_entry: Cannot allocate listneres\n");
+               panic("netlink_add_usersock_entry: Cannot allocate listeners\n");
 
        netlink_table_grab();
 
        nl_table[NETLINK_USERSOCK].groups = groups;
-       nl_table[NETLINK_USERSOCK].listeners = listeners;
+       rcu_assign_pointer(nl_table[NETLINK_USERSOCK].listeners, listeners);
        nl_table[NETLINK_USERSOCK].module = THIS_MODULE;
        nl_table[NETLINK_USERSOCK].registered = 1;