Commit a30cc9b2 authored by Fan Gong's avatar Fan Gong Committed by Paolo Abeni
Browse files

hinic3: Add PF management interfaces

parent 53200a86
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ enum mgmt_mod_type {
	/* Configuration module */
	MGMT_MOD_CFGM   = 7,
	MGMT_MOD_HILINK = 14,
	/* hardware max module id */
	MGMT_MOD_HW_MAX = 20,
};

static inline void mgmt_msg_params_init_default(struct mgmt_msg_params *msg_params,
+50 −1
Original line number Diff line number Diff line
@@ -211,6 +211,36 @@ static int init_ceqs_msix_attr(struct hinic3_hwdev *hwdev)
	return 0;
}

static int hinic3_comm_pf_to_mgmt_init(struct hinic3_hwdev *hwdev)
{
	int err;

	if (HINIC3_IS_VF(hwdev))
		return 0;

	err = hinic3_pf_to_mgmt_init(hwdev);
	if (err)
		return err;

	set_bit(HINIC3_HWDEV_MGMT_INITED, &hwdev->func_state);

	return 0;
}

static void hinic3_comm_pf_to_mgmt_free(struct hinic3_hwdev *hwdev)
{
	if (HINIC3_IS_VF(hwdev))
		return;

	spin_lock_bh(&hwdev->channel_lock);
	clear_bit(HINIC3_HWDEV_MGMT_INITED, &hwdev->func_state);
	spin_unlock_bh(&hwdev->channel_lock);

	hinic3_aeq_unregister_cb(hwdev, HINIC3_MSG_FROM_FW);

	hinic3_pf_to_mgmt_free(hwdev);
}

static int init_basic_mgmt_channel(struct hinic3_hwdev *hwdev)
{
	int err;
@@ -412,10 +442,14 @@ static int hinic3_init_comm_ch(struct hinic3_hwdev *hwdev)
	if (err)
		return err;

	err = init_basic_attributes(hwdev);
	err = hinic3_comm_pf_to_mgmt_init(hwdev);
	if (err)
		goto err_free_basic_mgmt_ch;

	err = init_basic_attributes(hwdev);
	if (err)
		goto err_free_comm_pf_to_mgmt;

	err = init_cmdqs_channel(hwdev);
	if (err) {
		dev_err(hwdev->dev, "Failed to init cmdq channel\n");
@@ -428,6 +462,8 @@ static int hinic3_init_comm_ch(struct hinic3_hwdev *hwdev)

err_clear_func_svc_used_state:
	hinic3_set_func_svc_used_state(hwdev, COMM_FUNC_SVC_T_COMM, 0);
err_free_comm_pf_to_mgmt:
	hinic3_comm_pf_to_mgmt_free(hwdev);
err_free_basic_mgmt_ch:
	free_base_mgmt_channel(hwdev);

@@ -439,6 +475,7 @@ static void hinic3_uninit_comm_ch(struct hinic3_hwdev *hwdev)
	hinic3_set_pf_status(hwdev->hwif, HINIC3_PF_STATUS_INIT);
	hinic3_free_cmdqs_channel(hwdev);
	hinic3_set_func_svc_used_state(hwdev, COMM_FUNC_SVC_T_COMM, 0);
	hinic3_comm_pf_to_mgmt_free(hwdev);
	free_base_mgmt_channel(hwdev);
}

@@ -581,9 +618,21 @@ void hinic3_free_hwdev(struct hinic3_hwdev *hwdev)

void hinic3_set_api_stop(struct hinic3_hwdev *hwdev)
{
	struct hinic3_recv_msg *recv_resp_msg;
	struct hinic3_mbox *mbox;

	spin_lock_bh(&hwdev->channel_lock);
	if (HINIC3_IS_PF(hwdev) &&
	    test_bit(HINIC3_HWDEV_MGMT_INITED, &hwdev->func_state)) {
		recv_resp_msg = &hwdev->pf_to_mgmt->recv_resp_msg_from_mgmt;
		spin_lock_bh(&hwdev->pf_to_mgmt->sync_event_lock);
		if (hwdev->pf_to_mgmt->event_flag == COMM_SEND_EVENT_START) {
			complete(&recv_resp_msg->recv_done);
			hwdev->pf_to_mgmt->event_flag = COMM_SEND_EVENT_TIMEOUT;
		}
		spin_unlock_bh(&hwdev->pf_to_mgmt->sync_event_lock);
	}

	if (test_bit(HINIC3_HWDEV_MBOX_INITED, &hwdev->func_state)) {
		mbox = hwdev->mbox;
		spin_lock(&mbox->mbox_lock);
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ struct hinic3_hwdev {
	struct hinic3_cmdqs         *cmdqs;
	struct delayed_work         sync_time_task;
	struct workqueue_struct     *workq;
	struct hinic3_msg_pf_to_mgmt *pf_to_mgmt;
	/* protect channel init and uninit */
	spinlock_t                  channel_lock;
	u64                         features[COMM_MAX_FEATURE_QWORD];
+2 −0
Original line number Diff line number Diff line
@@ -133,6 +133,8 @@ static int hinic3_sw_init(struct net_device *netdev)
	u8 mac_addr[ETH_ALEN];
	int err;

	mutex_init(&nic_dev->port_state_mutex);

	nic_dev->q_params.sq_depth = HINIC3_SQ_DEPTH;
	nic_dev->q_params.rq_depth = HINIC3_RQ_DEPTH;

+13 −0
Original line number Diff line number Diff line
@@ -864,6 +864,19 @@ int hinic3_send_mbox_to_mgmt(struct hinic3_hwdev *hwdev, u8 mod, u16 cmd,
	return err;
}

void hinic3_response_mbox_to_mgmt(struct hinic3_hwdev *hwdev, u8 mod, u16 cmd,
				  const void *buf_in, u32 in_size, u16 msg_id)
{
	struct mbox_msg_info msg_info;

	msg_info.msg_id = (u8)msg_id;
	msg_info.status = 0;

	send_mbox_msg(hwdev->mbox, mod, cmd, buf_in, in_size,
		      MBOX_MGMT_FUNC_ID, MBOX_MSG_RESP,
		      MBOX_MSG_NO_ACK, &msg_info);
}

int hinic3_send_mbox_to_mgmt_no_ack(struct hinic3_hwdev *hwdev, u8 mod, u16 cmd,
				    const struct mgmt_msg_params *msg_params)
{
Loading