Skip to content

Commit 59ccf86

Browse files
Sudarsana Reddy Kallurudavem330
authored andcommitted
qed: Add driver infrastucture for handling mfw requests.
MFW requests the TLVs in interrupt context. Extracting of the required data from upper layers and populating of the TLVs require process context. The patch adds work-queues for processing the tlv requests. It also adds the implementation for requesting the tlv values from appropriate protocol driver. Signed-off-by: Sudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com> Signed-off-by: Ariel Elior <ariel.elior@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 77a509e commit 59ccf86

4 files changed

Lines changed: 170 additions & 1 deletion

File tree

‎drivers/net/ethernet/qlogic/qed/qed.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ struct qed_simd_fp_handler {
515515
void (*func)(void *);
516516
};
517517

518+
enum qed_slowpath_wq_flag {
519+
QED_SLOWPATH_MFW_TLV_REQ,
520+
};
521+
518522
struct qed_hwfn {
519523
struct qed_dev *cdev;
520524
u8 my_id; /* ID inside the PF */
@@ -644,6 +648,9 @@ struct qed_hwfn {
644648
#endif
645649

646650
struct z_stream_s *stream;
651+
struct workqueue_struct *slowpath_wq;
652+
struct delayed_work slowpath_task;
653+
unsigned long slowpath_task_flags;
647654
};
648655

649656
struct pci_params {
@@ -908,6 +915,7 @@ void qed_get_protocol_stats(struct qed_dev *cdev,
908915
union qed_mcp_protocol_stats *stats);
909916
int qed_slowpath_irq_req(struct qed_hwfn *hwfn);
910917
void qed_slowpath_irq_sync(struct qed_hwfn *p_hwfn);
918+
int qed_mfw_tlv_req(struct qed_hwfn *hwfn);
911919

912920
int qed_mfw_fill_tlv_data(struct qed_hwfn *hwfn,
913921
enum qed_mfw_tlv_type type,

‎drivers/net/ethernet/qlogic/qed/qed_main.c‎

Lines changed: 150 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,68 @@ static void qed_update_pf_params(struct qed_dev *cdev,
946946
}
947947
}
948948

949+
static void qed_slowpath_wq_stop(struct qed_dev *cdev)
950+
{
951+
int i;
952+
953+
if (IS_VF(cdev))
954+
return;
955+
956+
for_each_hwfn(cdev, i) {
957+
if (!cdev->hwfns[i].slowpath_wq)
958+
continue;
959+
960+
flush_workqueue(cdev->hwfns[i].slowpath_wq);
961+
destroy_workqueue(cdev->hwfns[i].slowpath_wq);
962+
}
963+
}
964+
965+
static void qed_slowpath_task(struct work_struct *work)
966+
{
967+
struct qed_hwfn *hwfn = container_of(work, struct qed_hwfn,
968+
slowpath_task.work);
969+
struct qed_ptt *ptt = qed_ptt_acquire(hwfn);
970+
971+
if (!ptt) {
972+
queue_delayed_work(hwfn->slowpath_wq, &hwfn->slowpath_task, 0);
973+
return;
974+
}
975+
976+
if (test_and_clear_bit(QED_SLOWPATH_MFW_TLV_REQ,
977+
&hwfn->slowpath_task_flags))
978+
qed_mfw_process_tlv_req(hwfn, ptt);
979+
980+
qed_ptt_release(hwfn, ptt);
981+
}
982+
983+
static int qed_slowpath_wq_start(struct qed_dev *cdev)
984+
{
985+
struct qed_hwfn *hwfn;
986+
char name[NAME_SIZE];
987+
int i;
988+
989+
if (IS_VF(cdev))
990+
return 0;
991+
992+
for_each_hwfn(cdev, i) {
993+
hwfn = &cdev->hwfns[i];
994+
995+
snprintf(name, NAME_SIZE, "slowpath-%02x:%02x.%02x",
996+
cdev->pdev->bus->number,
997+
PCI_SLOT(cdev->pdev->devfn), hwfn->abs_pf_id);
998+
999+
hwfn->slowpath_wq = alloc_workqueue(name, 0, 0);
1000+
if (!hwfn->slowpath_wq) {
1001+
DP_NOTICE(hwfn, "Cannot create slowpath workqueue\n");
1002+
return -ENOMEM;
1003+
}
1004+
1005+
INIT_DELAYED_WORK(&hwfn->slowpath_task, qed_slowpath_task);
1006+
}
1007+
1008+
return 0;
1009+
}
1010+
9491011
static int qed_slowpath_start(struct qed_dev *cdev,
9501012
struct qed_slowpath_params *params)
9511013
{
@@ -961,6 +1023,9 @@ static int qed_slowpath_start(struct qed_dev *cdev,
9611023
if (qed_iov_wq_start(cdev))
9621024
goto err;
9631025

1026+
if (qed_slowpath_wq_start(cdev))
1027+
goto err;
1028+
9641029
if (IS_PF(cdev)) {
9651030
rc = request_firmware(&cdev->firmware, QED_FW_FILE_NAME,
9661031
&cdev->pdev->dev);
@@ -1095,6 +1160,8 @@ static int qed_slowpath_start(struct qed_dev *cdev,
10951160

10961161
qed_iov_wq_stop(cdev, false);
10971162

1163+
qed_slowpath_wq_stop(cdev);
1164+
10981165
return rc;
10991166
}
11001167

@@ -1103,6 +1170,8 @@ static int qed_slowpath_stop(struct qed_dev *cdev)
11031170
if (!cdev)
11041171
return -ENODEV;
11051172

1173+
qed_slowpath_wq_stop(cdev);
1174+
11061175
qed_ll2_dealloc_if(cdev);
11071176

11081177
if (IS_PF(cdev)) {
@@ -2089,8 +2158,88 @@ void qed_get_protocol_stats(struct qed_dev *cdev,
20892158
}
20902159
}
20912160

2161+
int qed_mfw_tlv_req(struct qed_hwfn *hwfn)
2162+
{
2163+
DP_VERBOSE(hwfn->cdev, NETIF_MSG_DRV,
2164+
"Scheduling slowpath task [Flag: %d]\n",
2165+
QED_SLOWPATH_MFW_TLV_REQ);
2166+
smp_mb__before_atomic();
2167+
set_bit(QED_SLOWPATH_MFW_TLV_REQ, &hwfn->slowpath_task_flags);
2168+
smp_mb__after_atomic();
2169+
queue_delayed_work(hwfn->slowpath_wq, &hwfn->slowpath_task, 0);
2170+
2171+
return 0;
2172+
}
2173+
2174+
static void
2175+
qed_fill_generic_tlv_data(struct qed_dev *cdev, struct qed_mfw_tlv_generic *tlv)
2176+
{
2177+
struct qed_common_cb_ops *op = cdev->protocol_ops.common;
2178+
struct qed_eth_stats_common *p_common;
2179+
struct qed_generic_tlvs gen_tlvs;
2180+
struct qed_eth_stats stats;
2181+
int i;
2182+
2183+
memset(&gen_tlvs, 0, sizeof(gen_tlvs));
2184+
op->get_generic_tlv_data(cdev->ops_cookie, &gen_tlvs);
2185+
2186+
if (gen_tlvs.feat_flags & QED_TLV_IP_CSUM)
2187+
tlv->flags.ipv4_csum_offload = true;
2188+
if (gen_tlvs.feat_flags & QED_TLV_LSO)
2189+
tlv->flags.lso_supported = true;
2190+
tlv->flags.b_set = true;
2191+
2192+
for (i = 0; i < QED_TLV_MAC_COUNT; i++) {
2193+
if (is_valid_ether_addr(gen_tlvs.mac[i])) {
2194+
ether_addr_copy(tlv->mac[i], gen_tlvs.mac[i]);
2195+
tlv->mac_set[i] = true;
2196+
}
2197+
}
2198+
2199+
qed_get_vport_stats(cdev, &stats);
2200+
p_common = &stats.common;
2201+
tlv->rx_frames = p_common->rx_ucast_pkts + p_common->rx_mcast_pkts +
2202+
p_common->rx_bcast_pkts;
2203+
tlv->rx_frames_set = true;
2204+
tlv->rx_bytes = p_common->rx_ucast_bytes + p_common->rx_mcast_bytes +
2205+
p_common->rx_bcast_bytes;
2206+
tlv->rx_bytes_set = true;
2207+
tlv->tx_frames = p_common->tx_ucast_pkts + p_common->tx_mcast_pkts +
2208+
p_common->tx_bcast_pkts;
2209+
tlv->tx_frames_set = true;
2210+
tlv->tx_bytes = p_common->tx_ucast_bytes + p_common->tx_mcast_bytes +
2211+
p_common->tx_bcast_bytes;
2212+
tlv->rx_bytes_set = true;
2213+
}
2214+
20922215
int qed_mfw_fill_tlv_data(struct qed_hwfn *hwfn, enum qed_mfw_tlv_type type,
20932216
union qed_mfw_tlv_data *tlv_buf)
20942217
{
2095-
return -EINVAL;
2218+
struct qed_dev *cdev = hwfn->cdev;
2219+
struct qed_common_cb_ops *ops;
2220+
2221+
ops = cdev->protocol_ops.common;
2222+
if (!ops || !ops->get_protocol_tlv_data || !ops->get_generic_tlv_data) {
2223+
DP_NOTICE(hwfn, "Can't collect TLV management info\n");
2224+
return -EINVAL;
2225+
}
2226+
2227+
switch (type) {
2228+
case QED_MFW_TLV_GENERIC:
2229+
qed_fill_generic_tlv_data(hwfn->cdev, &tlv_buf->generic);
2230+
break;
2231+
case QED_MFW_TLV_ETH:
2232+
ops->get_protocol_tlv_data(cdev->ops_cookie, &tlv_buf->eth);
2233+
break;
2234+
case QED_MFW_TLV_FCOE:
2235+
ops->get_protocol_tlv_data(cdev->ops_cookie, &tlv_buf->fcoe);
2236+
break;
2237+
case QED_MFW_TLV_ISCSI:
2238+
ops->get_protocol_tlv_data(cdev->ops_cookie, &tlv_buf->iscsi);
2239+
break;
2240+
default:
2241+
break;
2242+
}
2243+
2244+
return 0;
20962245
}

‎drivers/net/ethernet/qlogic/qed/qed_mcp.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,8 @@ int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
16221622
case MFW_DRV_MSG_S_TAG_UPDATE:
16231623
qed_mcp_update_stag(p_hwfn, p_ptt);
16241624
break;
1625+
case MFW_DRV_MSG_GET_TLV_REQ:
1626+
qed_mfw_tlv_req(p_hwfn);
16251627
break;
16261628
default:
16271629
DP_INFO(p_hwfn, "Unimplemented MFW message %d\n", i);

‎include/linux/qed/qed_if.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,14 @@ struct qed_int_info {
751751
u8 used_cnt;
752752
};
753753

754+
struct qed_generic_tlvs {
755+
#define QED_TLV_IP_CSUM BIT(0)
756+
#define QED_TLV_LSO BIT(1)
757+
u16 feat_flags;
758+
#define QED_TLV_MAC_COUNT 3
759+
u8 mac[QED_TLV_MAC_COUNT][ETH_ALEN];
760+
};
761+
754762
#define QED_NVM_SIGNATURE 0x12435687
755763

756764
enum qed_nvm_flash_cmd {
@@ -765,6 +773,8 @@ struct qed_common_cb_ops {
765773
void (*link_update)(void *dev,
766774
struct qed_link_output *link);
767775
void (*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
776+
void (*get_generic_tlv_data)(void *dev, struct qed_generic_tlvs *data);
777+
void (*get_protocol_tlv_data)(void *dev, void *data);
768778
};
769779

770780
struct qed_selftest_ops {

0 commit comments

Comments
 (0)