net: add rte prefix to ether structures
[dpdk.git] / drivers / net / atlantic / atl_ethdev.c
index 4e6124a..9460318 100644 (file)
@@ -93,14 +93,14 @@ static void atl_dev_interrupt_handler(void *param);
 
 
 static int atl_add_mac_addr(struct rte_eth_dev *dev,
-                           struct ether_addr *mac_addr,
+                           struct rte_ether_addr *mac_addr,
                            uint32_t index, uint32_t pool);
 static void atl_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
 static int atl_set_default_mac_addr(struct rte_eth_dev *dev,
-                                          struct ether_addr *mac_addr);
+                                          struct rte_ether_addr *mac_addr);
 
 static int atl_dev_set_mc_addr_list(struct rte_eth_dev *dev,
-                                   struct ether_addr *mc_addr_set,
+                                   struct rte_ether_addr *mc_addr_set,
                                    uint32_t nb_mc_addr);
 
 /* RSS */
@@ -179,6 +179,8 @@ static struct rte_pci_driver rte_atl_pmd = {
                        | DEV_TX_OFFLOAD_MACSEC_INSERT \
                        | DEV_TX_OFFLOAD_MULTI_SEGS)
 
+#define SFP_EEPROM_SIZE 0x100
+
 static const struct rte_eth_desc_lim rx_desc_lim = {
        .nb_max = ATL_MAX_RING_DESC,
        .nb_min = ATL_MIN_RING_DESC,
@@ -600,9 +602,6 @@ atl_dev_start(struct rte_eth_dev *dev)
 
        dev->data->dev_link.link_status = hw->aq_link_status.mbps != 0;
 
-       if (err)
-               goto error;
-
        if (rte_intr_allow_others(intr_handle)) {
                /* check if lsc interrupt is enabled */
                if (dev->data->dev_conf.intr_conf.lsc != 0)
@@ -1158,6 +1157,7 @@ atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused)
 {
        struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct rte_eth_link link, old;
+       u32 fc = AQ_NIC_FC_OFF;
        int err = 0;
 
        link.link_status = ETH_LINK_DOWN;
@@ -1192,6 +1192,15 @@ atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused)
        if (link.link_status == old.link_status)
                return -1;
 
+       /* Driver has to update flow control settings on RX block
+        * on any link event.
+        * We should query FW whether it negotiated FC.
+        */
+       if (hw->aq_fw_ops->get_flow_control) {
+               hw->aq_fw_ops->get_flow_control(hw, &fc);
+               hw_atl_b0_set_fc(hw, fc, 0U);
+       }
+
        if (rte_eal_alarm_set(1000 * 1000,
                              atl_dev_delayed_handler, (void *)dev) < 0)
                PMD_DRV_LOG(ERR, "rte_eal_alarm_set fail");
@@ -1411,7 +1420,6 @@ atl_dev_interrupt_handler(void *param)
        atl_dev_interrupt_action(dev, dev->intr_handle);
 }
 
-#define SFP_EEPROM_SIZE 0xff
 
 static int
 atl_dev_get_eeprom_length(struct rte_eth_dev *dev __rte_unused)
@@ -1432,6 +1440,9 @@ int atl_dev_get_eeprom(struct rte_eth_dev *dev,
            eeprom->data == NULL)
                return -EINVAL;
 
+       if (eeprom->magic > 0x7F)
+               return -EINVAL;
+
        if (eeprom->magic)
                dev_addr = eeprom->magic;
 
@@ -1448,14 +1459,18 @@ int atl_dev_set_eeprom(struct rte_eth_dev *dev,
        if (hw->aq_fw_ops->set_eeprom == NULL)
                return -ENOTSUP;
 
-       if (eeprom->length != SFP_EEPROM_SIZE || eeprom->data == NULL)
+       if (eeprom->length + eeprom->offset > SFP_EEPROM_SIZE ||
+           eeprom->data == NULL)
+               return -EINVAL;
+
+       if (eeprom->magic > 0x7F)
                return -EINVAL;
 
        if (eeprom->magic)
                dev_addr = eeprom->magic;
 
-       return hw->aq_fw_ops->set_eeprom(hw, dev_addr,
-                                        eeprom->data, eeprom->length);
+       return hw->aq_fw_ops->set_eeprom(hw, dev_addr, eeprom->data,
+                                        eeprom->length, eeprom->offset);
 }
 
 static int
@@ -1488,14 +1503,20 @@ static int
 atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 {
        struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       u32 fc = AQ_NIC_FC_OFF;
 
-       if (hw->aq_nic_cfg->flow_control == AQ_NIC_FC_OFF)
+       if (hw->aq_fw_ops->get_flow_control == NULL)
+               return -ENOTSUP;
+
+       hw->aq_fw_ops->get_flow_control(hw, &fc);
+
+       if (fc == AQ_NIC_FC_OFF)
                fc_conf->mode = RTE_FC_NONE;
-       else if (hw->aq_nic_cfg->flow_control & (AQ_NIC_FC_RX | AQ_NIC_FC_TX))
+       else if (fc & (AQ_NIC_FC_RX | AQ_NIC_FC_TX))
                fc_conf->mode = RTE_FC_FULL;
-       else if (hw->aq_nic_cfg->flow_control & AQ_NIC_FC_RX)
+       else if (fc & AQ_NIC_FC_RX)
                fc_conf->mode = RTE_FC_RX_PAUSE;
-       else if (hw->aq_nic_cfg->flow_control & AQ_NIC_FC_RX)
+       else if (fc & AQ_NIC_FC_RX)
                fc_conf->mode = RTE_FC_TX_PAUSE;
 
        return 0;
@@ -1554,7 +1575,7 @@ atl_update_mac_addr(struct rte_eth_dev *dev, uint32_t index,
 }
 
 static int
-atl_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
+atl_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
                        uint32_t index __rte_unused, uint32_t pool __rte_unused)
 {
        if (is_zero_ether_addr(mac_addr)) {
@@ -1572,7 +1593,7 @@ atl_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
 }
 
 static int
-atl_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
+atl_set_default_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *addr)
 {
        atl_remove_mac_addr(dev, 0);
        atl_add_mac_addr(dev, addr, 0, 0);
@@ -1739,7 +1760,7 @@ atl_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue_id, int on)
 
 static int
 atl_dev_set_mc_addr_list(struct rte_eth_dev *dev,
-                         struct ether_addr *mc_addr_set,
+                         struct rte_ether_addr *mc_addr_set,
                          uint32_t nb_mc_addr)
 {
        struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1879,4 +1900,3 @@ RTE_INIT(atl_init_log)
        if (atl_logtype_driver >= 0)
                rte_log_set_level(atl_logtype_driver, RTE_LOG_NOTICE);
 }
-