be2net: Fix setting QoS for VF for Lancer
authorPadmanabh Ratnakar <padmanabh.ratnakar@emulex.com>
Sat, 20 Oct 2012 06:01:53 +0000 (06:01 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Oct 2012 02:15:35 +0000 (22:15 -0400)
Use Lancer specific command to set QoS for VF.

Signed-off-by: Padmanabh Ratnakar <padmanabh.ratnakar@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/emulex/benet/be.h
drivers/net/ethernet/emulex/benet/be_cmds.c
drivers/net/ethernet/emulex/benet/be_cmds.h
drivers/net/ethernet/emulex/benet/be_main.c

index dc6ec6b7fbffa797da623910f3d4b68d7a723c44..3b8ef4b8b025016e28d6d9b9fb1f0c62b77fbaf4 100644 (file)
@@ -444,6 +444,7 @@ struct be_adapter {
        u16 max_vlans;
        u16 max_event_queues;
        u32 if_cap_flags;
+       u8 pf_number;
 };
 
 #define be_physfn(adapter)             (!adapter->virtfn)
index 094b5f322050c71f860b341b18f5176262805d5a..3980b5815d8d7763937db1ee4e9bbb80c6e2c9b8 100644 (file)
@@ -2862,6 +2862,7 @@ int be_cmd_get_func_config(struct be_adapter *adapter)
                        goto err;
                }
 
+               adapter->pf_number = desc->pf_num;
                adapter->max_pmac_cnt = le16_to_cpu(desc->unicast_mac_count);
                adapter->max_vlans = le16_to_cpu(desc->vlan_count);
                adapter->max_mcast_mac = le16_to_cpu(desc->mcast_mac_count);
@@ -2936,6 +2937,63 @@ err:
        return status;
 }
 
+/* Uses sync mcc */
+int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps,
+                             u8 domain)
+{
+       struct be_mcc_wrb *wrb;
+       struct be_cmd_req_set_profile_config *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_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
+                              OPCODE_COMMON_SET_PROFILE_CONFIG, sizeof(*req),
+                              wrb, NULL);
+
+       req->hdr.domain = domain;
+       req->desc_count = cpu_to_le32(1);
+
+       req->nic_desc.desc_type = NIC_RESOURCE_DESC_TYPE_ID;
+       req->nic_desc.desc_len = RESOURCE_DESC_SIZE;
+       req->nic_desc.flags = (1 << QUN) | (1 << IMM) | (1 << NOSV);
+       req->nic_desc.pf_num = adapter->pf_number;
+       req->nic_desc.vf_num = domain;
+
+       /* Mark fields invalid */
+       req->nic_desc.unicast_mac_count = 0xFFFF;
+       req->nic_desc.mcc_count = 0xFFFF;
+       req->nic_desc.vlan_count = 0xFFFF;
+       req->nic_desc.mcast_mac_count = 0xFFFF;
+       req->nic_desc.txq_count = 0xFFFF;
+       req->nic_desc.rq_count = 0xFFFF;
+       req->nic_desc.rssq_count = 0xFFFF;
+       req->nic_desc.lro_count = 0xFFFF;
+       req->nic_desc.cq_count = 0xFFFF;
+       req->nic_desc.toe_conn_count = 0xFFFF;
+       req->nic_desc.eq_count = 0xFFFF;
+       req->nic_desc.link_param = 0xFF;
+       req->nic_desc.bw_min = 0xFFFFFFFF;
+       req->nic_desc.acpi_params = 0xFF;
+       req->nic_desc.wol_param = 0x0F;
+
+       /* Change BW */
+       req->nic_desc.bw_min = cpu_to_le32(bps);
+       req->nic_desc.bw_max = cpu_to_le32(bps);
+       status = be_mcc_notify_wait(adapter);
+err:
+       spin_unlock_bh(&adapter->mcc_lock);
+       return status;
+}
+
 int be_roce_mcc_cmd(void *netdev_handle, void *wrb_payload,
                        int wrb_payload_size, u16 *cmd_status, u16 *ext_status)
 {
index c2bf4dfdb6902f430a2a79b65644ccf45e9957ed..ad16d31b86d71b5df3bc1fe65ce61f8e19eab44f 100644 (file)
@@ -198,6 +198,7 @@ struct be_mcc_mailbox {
 #define OPCODE_COMMON_GET_HSW_CONFIG                   152
 #define OPCODE_COMMON_GET_FUNC_CONFIG                  160
 #define OPCODE_COMMON_GET_PROFILE_CONFIG               164
+#define OPCODE_COMMON_SET_PROFILE_CONFIG               165
 #define OPCODE_COMMON_SET_HSW_CONFIG                   153
 #define OPCODE_COMMON_READ_OBJECT                      171
 #define OPCODE_COMMON_WRITE_OBJECT                     172
@@ -1689,6 +1690,14 @@ struct be_cmd_req_set_ext_fat_caps {
 #define RESOURCE_DESC_SIZE                     72
 #define NIC_RESOURCE_DESC_TYPE_ID              0x41
 #define MAX_RESOURCE_DESC                      4
+
+/* QOS unit number */
+#define QUN                                    4
+/* Immediate */
+#define IMM                                    6
+/* No save */
+#define NOSV                                   7
+
 struct be_nic_resource_desc {
        u8 desc_type;
        u8 desc_len;
@@ -1746,6 +1755,17 @@ struct be_cmd_resp_get_profile_config {
        u8 func_param[MAX_RESOURCE_DESC * RESOURCE_DESC_SIZE];
 };
 
+struct be_cmd_req_set_profile_config {
+       struct be_cmd_req_hdr hdr;
+       u32 rsvd;
+       u32 desc_count;
+       struct be_nic_resource_desc nic_desc;
+};
+
+struct be_cmd_resp_set_profile_config {
+       struct be_cmd_req_hdr hdr;
+};
+
 extern int be_pci_fnum_get(struct be_adapter *adapter);
 extern int be_fw_wait_ready(struct be_adapter *adapter);
 extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
@@ -1863,3 +1883,6 @@ extern int be_cmd_query_port_name(struct be_adapter *adapter, u8 *port_name);
 extern int be_cmd_get_func_config(struct be_adapter *adapter);
 extern int be_cmd_get_profile_config(struct be_adapter *adapter, u32 *cap_flags,
                                     u8 domain);
+
+extern int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps,
+                                    u8 domain);
index 9b734a0f8efa0ce2202702dd1eefd00cd5c71770..0b49201b8b4595fbd64b24676dde5828e44d2dfc 100644 (file)
@@ -1062,7 +1062,10 @@ static int be_set_vf_tx_rate(struct net_device *netdev,
                return -EINVAL;
        }
 
-       status = be_cmd_set_qos(adapter, rate / 10, vf + 1);
+       if (lancer_chip(adapter))
+               status = be_cmd_set_profile_config(adapter, rate / 10, vf + 1);
+       else
+               status = be_cmd_set_qos(adapter, rate / 10, vf + 1);
 
        if (status)
                dev_err(&adapter->pdev->dev,