Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[cascardo/linux.git] / drivers / net / ethernet / chelsio / cxgb4 / t4_hw.c
index 660204b..20dec85 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the Chelsio T4 Ethernet driver for Linux.
  *
- * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
+ * Copyright (c) 2003-2016 Chelsio Communications, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -2729,7 +2729,7 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p)
 
 out:
        vfree(vpd);
-       return ret;
+       return ret < 0 ? ret : 0;
 }
 
 /**
@@ -8269,3 +8269,73 @@ void t4_idma_monitor(struct adapter *adapter,
                t4_sge_decode_idma_state(adapter, idma->idma_state[i]);
        }
 }
+
+/**
+ *     t4_set_vf_mac - Set MAC address for the specified VF
+ *     @adapter: The adapter
+ *     @vf: one of the VFs instantiated by the specified PF
+ *     @naddr: the number of MAC addresses
+ *     @addr: the MAC address(es) to be set to the specified VF
+ */
+int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
+                     unsigned int naddr, u8 *addr)
+{
+       struct fw_acl_mac_cmd cmd;
+
+       memset(&cmd, 0, sizeof(cmd));
+       cmd.op_to_vfn = cpu_to_be32(FW_CMD_OP_V(FW_ACL_MAC_CMD) |
+                                   FW_CMD_REQUEST_F |
+                                   FW_CMD_WRITE_F |
+                                   FW_ACL_MAC_CMD_PFN_V(adapter->pf) |
+                                   FW_ACL_MAC_CMD_VFN_V(vf));
+
+       /* Note: Do not enable the ACL */
+       cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
+       cmd.nmac = naddr;
+
+       switch (adapter->pf) {
+       case 3:
+               memcpy(cmd.macaddr3, addr, sizeof(cmd.macaddr3));
+               break;
+       case 2:
+               memcpy(cmd.macaddr2, addr, sizeof(cmd.macaddr2));
+               break;
+       case 1:
+               memcpy(cmd.macaddr1, addr, sizeof(cmd.macaddr1));
+               break;
+       case 0:
+               memcpy(cmd.macaddr0, addr, sizeof(cmd.macaddr0));
+               break;
+       }
+
+       return t4_wr_mbox(adapter, adapter->mbox, &cmd, sizeof(cmd), &cmd);
+}
+
+int t4_sched_params(struct adapter *adapter, int type, int level, int mode,
+                   int rateunit, int ratemode, int channel, int class,
+                   int minrate, int maxrate, int weight, int pktsize)
+{
+       struct fw_sched_cmd cmd;
+
+       memset(&cmd, 0, sizeof(cmd));
+       cmd.op_to_write = cpu_to_be32(FW_CMD_OP_V(FW_SCHED_CMD) |
+                                     FW_CMD_REQUEST_F |
+                                     FW_CMD_WRITE_F);
+       cmd.retval_len16 = cpu_to_be32(FW_LEN16(cmd));
+
+       cmd.u.params.sc = FW_SCHED_SC_PARAMS;
+       cmd.u.params.type = type;
+       cmd.u.params.level = level;
+       cmd.u.params.mode = mode;
+       cmd.u.params.ch = channel;
+       cmd.u.params.cl = class;
+       cmd.u.params.unit = rateunit;
+       cmd.u.params.rate = ratemode;
+       cmd.u.params.min = cpu_to_be32(minrate);
+       cmd.u.params.max = cpu_to_be32(maxrate);
+       cmd.u.params.weight = cpu_to_be16(weight);
+       cmd.u.params.pktsize = cpu_to_be16(pktsize);
+
+       return t4_wr_mbox_meat(adapter, adapter->mbox, &cmd, sizeof(cmd),
+                              NULL, 1);
+}