X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_pmd_e1000%2Figb_pf.c;h=bc3816a7591be70a6c311aab61067ef2b36fe6f1;hb=76d5b807ff7456217311f6e47e610b7d762a3daf;hp=e7c1de62d3230a5185d0f49b6a847785ffe99eb4;hpb=be2d648a2dd34a69810bdac2345f717ab6f81ca8;p=dpdk.git diff --git a/lib/librte_pmd_e1000/igb_pf.c b/lib/librte_pmd_e1000/igb_pf.c index e7c1de62d3..bc3816a759 100644 --- a/lib/librte_pmd_e1000/igb_pf.c +++ b/lib/librte_pmd_e1000/igb_pf.c @@ -1,35 +1,34 @@ /*- * BSD LICENSE - * - * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ #include @@ -55,35 +54,24 @@ #include "e1000/e1000_hw.h" #include "e1000_ethdev.h" -static inline -void eth_random_addr(uint8_t *addr) -{ - uint64_t rand = rte_rand(); - uint8_t *p = (uint8_t*)&rand; - - rte_memcpy(addr, p, ETHER_ADDR_LEN); - addr[0] &= 0xfe; /* clear multicast bit */ - addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ -} - static inline uint16_t dev_num_vf(struct rte_eth_dev *eth_dev) { return eth_dev->pci_dev->max_vfs; } -static inline +static inline int igb_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num) { unsigned char vf_mac_addr[ETHER_ADDR_LEN]; - struct e1000_vf_info *vfinfo = + struct e1000_vf_info *vfinfo = *E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private); uint16_t vfn; for (vfn = 0; vfn < vf_num; vfn++) { eth_random_addr(vf_mac_addr); /* keep the random address as default */ - memcpy(vfinfo[vfn].vf_mac_addresses, vf_mac_addr, + memcpy(vfinfo[vfn].vf_mac_addresses, vf_mac_addr, ETHER_ADDR_LEN); } @@ -103,9 +91,9 @@ igb_mb_intr_setup(struct rte_eth_dev *dev) void igb_pf_host_init(struct rte_eth_dev *eth_dev) { - struct e1000_vf_info **vfinfo = + struct e1000_vf_info **vfinfo = E1000_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private); - struct e1000_hw *hw = + struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); uint16_t vf_num; uint8_t nb_queue; @@ -144,7 +132,7 @@ int igb_pf_host_configure(struct rte_eth_dev *eth_dev) { uint32_t vtctl; uint16_t vf_num; - struct e1000_hw *hw = + struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); uint32_t vlanctrl; int i; @@ -156,7 +144,7 @@ int igb_pf_host_configure(struct rte_eth_dev *eth_dev) /* enable VMDq and set the default pool for PF */ vtctl = E1000_READ_REG(hw, E1000_VT_CTL); vtctl &= ~E1000_VT_CTL_DEFAULT_POOL_MASK; - vtctl |= RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx + vtctl |= RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx << E1000_VT_CTL_DEFAULT_POOL_SHIFT; vtctl |= E1000_VT_CTL_VM_REPL_EN; E1000_WRITE_REG(hw, E1000_VT_CTL, vtctl); @@ -188,7 +176,7 @@ int igb_pf_host_configure(struct rte_eth_dev *eth_dev) E1000_WRITE_REG(hw, E1000_RAH(0), rah); /* - * enable vlan filtering and allow all vlan tags through + * enable vlan filtering and allow all vlan tags through */ vlanctrl = E1000_READ_REG(hw, E1000_RCTL); vlanctrl |= E1000_RCTL_VFE ; /* enable vlan filters */ @@ -198,17 +186,17 @@ int igb_pf_host_configure(struct rte_eth_dev *eth_dev) for (i = 0; i < IGB_VFTA_SIZE; i++) { E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, i, 0xFFFFFFFF); } - + /* Enable/Disable MAC Anti-Spoofing */ e1000_vmdq_set_anti_spoofing_pf(hw, FALSE, vf_num); return 0; } -static void +static void set_rx_mode(struct rte_eth_dev *dev) { - struct rte_eth_dev_data *dev_data = + struct rte_eth_dev_data *dev_data = (struct rte_eth_dev_data*)dev->data->dev_private; struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); uint32_t fctrl, vmolr = E1000_VMOLR_BAM | E1000_VMOLR_AUPE; @@ -247,21 +235,21 @@ set_rx_mode(struct rte_eth_dev *dev) E1000_WRITE_REG(hw, E1000_RCTL, fctrl); } -static inline void +static inline void igb_vf_reset_event(struct rte_eth_dev *dev, uint16_t vf) { - struct e1000_hw *hw = + struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct e1000_vf_info *vfinfo = + struct e1000_vf_info *vfinfo = *(E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private)); uint32_t vmolr = E1000_READ_REG(hw, E1000_VMOLR(vf)); - vmolr |= (E1000_VMOLR_ROPE | E1000_VMOLR_ROMPE | + vmolr |= (E1000_VMOLR_ROPE | E1000_VMOLR_ROMPE | E1000_VMOLR_BAM | E1000_VMOLR_AUPE); E1000_WRITE_REG(hw, E1000_VMOLR(vf), vmolr); E1000_WRITE_REG(hw, E1000_VMVIR(vf), 0); - + /* reset multicast table array for vf */ vfinfo[vf].num_vf_mc_hashes = 0; @@ -269,7 +257,7 @@ igb_vf_reset_event(struct rte_eth_dev *dev, uint16_t vf) set_rx_mode(dev); } -static inline void +static inline void igb_vf_reset_msg(struct rte_eth_dev *dev, uint16_t vf) { struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -291,7 +279,7 @@ static int igb_vf_reset(struct rte_eth_dev *dev, uint16_t vf, uint32_t *msgbuf) { struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct e1000_vf_info *vfinfo = + struct e1000_vf_info *vfinfo = *(E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private)); unsigned char *vf_mac = vfinfo[vf].vf_mac_addresses; int rar_entry = hw->mac.rar_entry_count - (vf + 1); @@ -317,7 +305,7 @@ static int igb_vf_set_mac_addr(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf) { struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct e1000_vf_info *vfinfo = + struct e1000_vf_info *vfinfo = *(E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private)); int rar_entry = hw->mac.rar_entry_count - (vf + 1); uint8_t *new_mac = (uint8_t *)(&msgbuf[1]); @@ -337,11 +325,11 @@ igb_vf_set_multicast(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t uint32_t vector_bit; uint32_t vector_reg; uint32_t mta_reg; - int entries = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >> + int entries = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >> E1000_VT_MSGINFO_SHIFT; uint16_t *hash_list = (uint16_t *)&msgbuf[1]; struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct e1000_vf_info *vfinfo = + struct e1000_vf_info *vfinfo = *(E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private)); /* only so many hash values supported */ @@ -378,7 +366,7 @@ igb_vf_set_vlan(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf) { int add, vid; struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct e1000_vf_info *vfinfo = + struct e1000_vf_info *vfinfo = *(E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private)); uint32_t vid_idx, vid_bit, vfta; @@ -391,7 +379,7 @@ igb_vf_set_vlan(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf) else if (vfinfo[vf].vlan_count) vfinfo[vf].vlan_count--; - vid_idx = (uint32_t)((vid >> E1000_VFTA_ENTRY_SHIFT) & + vid_idx = (uint32_t)((vid >> E1000_VFTA_ENTRY_SHIFT) & E1000_VFTA_ENTRY_MASK); vid_bit = (uint32_t)(1 << (vid & E1000_VFTA_ENTRY_BIT_SHIFT_MASK)); vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, vid_idx); @@ -399,14 +387,14 @@ igb_vf_set_vlan(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf) vfta |= vid_bit; else vfta &= ~vid_bit; - + E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, vid_idx, vfta); E1000_WRITE_FLUSH(hw); return 0; } -static int +static int igb_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf) { uint16_t mbx_size = E1000_VFMAILBOX_SIZE; @@ -416,7 +404,7 @@ igb_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf) retval = e1000_read_mbx(hw, msgbuf, mbx_size, vf); if (retval) { - RTE_LOG(ERR, PMD, "Error mbx recv msg from VF %d\n", vf); + PMD_INIT_LOG(ERR, "Error mbx recv msg from VF %d", vf); return retval; } @@ -444,7 +432,8 @@ igb_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf) retval = igb_vf_set_vlan(dev, vf, msgbuf); break; default: - RTE_LOG(DEBUG, PMD, "Unhandled Msg %8.8x\n", (unsigned) msgbuf[0]); + PMD_INIT_LOG(DEBUG, "Unhandled Msg %8.8x", + (unsigned) msgbuf[0]); retval = E1000_ERR_MBX; break; } @@ -462,11 +451,11 @@ igb_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf) return retval; } -static inline void +static inline void igb_rcv_ack_from_vf(struct rte_eth_dev *dev, uint16_t vf) { uint32_t msg = E1000_VT_MSGTYPE_NACK; - struct e1000_hw *hw = + struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); e1000_write_mbx(hw, &msg, 1, vf); @@ -475,7 +464,7 @@ igb_rcv_ack_from_vf(struct rte_eth_dev *dev, uint16_t vf) void igb_pf_mbx_process(struct rte_eth_dev *eth_dev) { uint16_t vf; - struct e1000_hw *hw = + struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); for (vf = 0; vf < dev_num_vf(eth_dev); vf++) {