Skip to content

Commit c78c70f

Browse files
Sudarsana Reddy Kallurudavem330
authored andcommitted
qed: Add infrastructure for PTP support
The patch adds the required qed interfaces for configuring/reading the PTP clock on the adapter. Signed-off-by: Sudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com> Signed-off-by: Yuval Mintz <Yuval.Mintz@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b93f79b commit c78c70f

File tree

9 files changed

+447
-1
lines changed

9 files changed

+447
-1
lines changed

drivers/net/ethernet/qlogic/qed/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ obj-$(CONFIG_QED) := qed.o
22

33
qed-y := qed_cxt.o qed_dev.o qed_hw.o qed_init_fw_funcs.o qed_init_ops.o \
44
qed_int.o qed_main.o qed_mcp.o qed_sp_commands.o qed_spq.o qed_l2.o \
5-
qed_selftest.o qed_dcbx.o qed_debug.o
5+
qed_selftest.o qed_dcbx.o qed_debug.o qed_ptp.o
66
qed-$(CONFIG_QED_SRIOV) += qed_sriov.o qed_vf.o
77
qed-$(CONFIG_QED_LL2) += qed_ll2.o
88
qed-$(CONFIG_QED_RDMA) += qed_roce.o

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ struct qed_hwfn {
456456
u8 dcbx_no_edpm;
457457
u8 db_bar_no_edpm;
458458

459+
/* p_ptp_ptt is valid for leading HWFN only */
460+
struct qed_ptt *p_ptp_ptt;
459461
struct qed_simd_fp_handler simd_proto_handler[64];
460462

461463
#ifdef CONFIG_QED_SRIOV

drivers/net/ethernet/qlogic/qed/qed_l2.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
214214
p_ramrod->vport_id = abs_vport_id;
215215

216216
p_ramrod->mtu = cpu_to_le16(p_params->mtu);
217+
p_ramrod->handle_ptp_pkts = p_params->handle_ptp_pkts;
217218
p_ramrod->inner_vlan_removal_en = p_params->remove_inner_vlan;
218219
p_ramrod->drop_ttl0_en = p_params->drop_ttl0;
219220
p_ramrod->untagged = p_params->only_untagged;
@@ -1886,6 +1887,7 @@ static int qed_start_vport(struct qed_dev *cdev,
18861887
start.drop_ttl0 = params->drop_ttl0;
18871888
start.opaque_fid = p_hwfn->hw_info.opaque_fid;
18881889
start.concrete_fid = p_hwfn->hw_info.concrete_fid;
1890+
start.handle_ptp_pkts = params->handle_ptp_pkts;
18891891
start.vport_id = params->vport_id;
18901892
start.max_buffers_per_cqe = 16;
18911893
start.mtu = params->mtu;
@@ -2328,6 +2330,8 @@ extern const struct qed_iov_hv_ops qed_iov_ops_pass;
23282330
extern const struct qed_eth_dcbnl_ops qed_dcbnl_ops_pass;
23292331
#endif
23302332

2333+
extern const struct qed_eth_ptp_ops qed_ptp_ops_pass;
2334+
23312335
static const struct qed_eth_ops qed_eth_ops_pass = {
23322336
.common = &qed_common_ops_pass,
23332337
#ifdef CONFIG_QED_SRIOV
@@ -2336,6 +2340,7 @@ static const struct qed_eth_ops qed_eth_ops_pass = {
23362340
#ifdef CONFIG_DCB
23372341
.dcb = &qed_dcbnl_ops_pass,
23382342
#endif
2343+
.ptp = &qed_ptp_ops_pass,
23392344
.fill_dev_info = &qed_fill_eth_dev_info,
23402345
.register_ops = &qed_register_eth_ops,
23412346
.check_mac = &qed_check_mac,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ struct qed_sp_vport_start_params {
156156
enum qed_tpa_mode tpa_mode;
157157
bool remove_inner_vlan;
158158
bool tx_switching;
159+
bool handle_ptp_pkts;
159160
bool only_untagged;
160161
bool drop_ttl0;
161162
u8 max_buffers_per_cqe;

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ static int qed_slowpath_start(struct qed_dev *cdev,
902902
struct qed_mcp_drv_version drv_version;
903903
const u8 *data = NULL;
904904
struct qed_hwfn *hwfn;
905+
struct qed_ptt *p_ptt;
905906
int rc = -EINVAL;
906907

907908
if (qed_iov_wq_start(cdev))
@@ -916,6 +917,14 @@ static int qed_slowpath_start(struct qed_dev *cdev,
916917
QED_FW_FILE_NAME);
917918
goto err;
918919
}
920+
921+
p_ptt = qed_ptt_acquire(QED_LEADING_HWFN(cdev));
922+
if (p_ptt) {
923+
QED_LEADING_HWFN(cdev)->p_ptp_ptt = p_ptt;
924+
} else {
925+
DP_NOTICE(cdev, "Failed to acquire PTT for PTP\n");
926+
goto err;
927+
}
919928
}
920929

921930
cdev->rx_coalesce_usecs = QED_DEFAULT_RX_USECS;
@@ -1003,6 +1012,10 @@ static int qed_slowpath_start(struct qed_dev *cdev,
10031012
if (IS_PF(cdev))
10041013
release_firmware(cdev->firmware);
10051014

1015+
if (IS_PF(cdev) && QED_LEADING_HWFN(cdev)->p_ptp_ptt)
1016+
qed_ptt_release(QED_LEADING_HWFN(cdev),
1017+
QED_LEADING_HWFN(cdev)->p_ptp_ptt);
1018+
10061019
qed_iov_wq_stop(cdev, false);
10071020

10081021
return rc;
@@ -1016,6 +1029,8 @@ static int qed_slowpath_stop(struct qed_dev *cdev)
10161029
qed_ll2_dealloc_if(cdev);
10171030

10181031
if (IS_PF(cdev)) {
1032+
qed_ptt_release(QED_LEADING_HWFN(cdev),
1033+
QED_LEADING_HWFN(cdev)->p_ptp_ptt);
10191034
qed_free_stream_mem(cdev);
10201035
if (IS_QED_ETH_IF(cdev))
10211036
qed_sriov_disable(cdev, true);

0 commit comments

Comments
 (0)