Skip to content

Commit d31ad61

Browse files
Sricharan Randersson
authored andcommitted
rpmsg: glink: Add support for transport version negotiation
G-link supports a version number and feature flags for each transport. A combination of the version number and feature flags enable/disable: (*) G-Link software updates for each edge (*) Individual features for each edge Endpoints negotiate both the version and the supported flags when the transport is opened and they cannot be changed after negotiation has been completed. Each full implementation of G-Link must support a minimum of the current version, the previous version, and the base negotiation version called v0. Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org> Signed-off-by: Sricharan R <sricharan@codeaurora.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
1 parent caf989c commit d31ad61

4 files changed

Lines changed: 79 additions & 6 deletions

File tree

‎drivers/rpmsg/qcom_glink_native.c‎

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "qcom_glink_native.h"
3232

3333
#define GLINK_NAME_SIZE 32
34+
#define GLINK_VERSION_1 1
3435

3536
#define RPM_GLINK_CID_MIN 1
3637
#define RPM_GLINK_CID_MAX 65536
@@ -94,6 +95,9 @@ struct qcom_glink {
9495
struct mutex idr_lock;
9596
struct idr lcids;
9697
struct idr rcids;
98+
unsigned long features;
99+
100+
bool intentless;
97101
};
98102

99103
enum {
@@ -256,8 +260,8 @@ static int qcom_glink_send_version(struct qcom_glink *glink)
256260
struct glink_msg msg;
257261

258262
msg.cmd = cpu_to_le16(RPM_CMD_VERSION);
259-
msg.param1 = cpu_to_le16(1);
260-
msg.param2 = cpu_to_le32(GLINK_FEATURE_INTENTLESS);
263+
msg.param1 = cpu_to_le16(GLINK_VERSION_1);
264+
msg.param2 = cpu_to_le32(glink->features);
261265

262266
return qcom_glink_tx(glink, &msg, sizeof(msg), NULL, 0, true);
263267
}
@@ -267,8 +271,8 @@ static void qcom_glink_send_version_ack(struct qcom_glink *glink)
267271
struct glink_msg msg;
268272

269273
msg.cmd = cpu_to_le16(RPM_CMD_VERSION_ACK);
270-
msg.param1 = cpu_to_le16(1);
271-
msg.param2 = cpu_to_le32(0);
274+
msg.param1 = cpu_to_le16(GLINK_VERSION_1);
275+
msg.param2 = cpu_to_le32(glink->features);
272276

273277
qcom_glink_tx(glink, &msg, sizeof(msg), NULL, 0, true);
274278
}
@@ -362,6 +366,63 @@ static void qcom_glink_send_close_ack(struct qcom_glink *glink,
362366
qcom_glink_tx(glink, &req, sizeof(req), NULL, 0, true);
363367
}
364368

369+
/**
370+
* qcom_glink_receive_version() - receive version/features from remote system
371+
*
372+
* @glink: pointer to transport interface
373+
* @r_version: remote version
374+
* @r_features: remote features
375+
*
376+
* This function is called in response to a remote-initiated version/feature
377+
* negotiation sequence.
378+
*/
379+
static void qcom_glink_receive_version(struct qcom_glink *glink,
380+
u32 version,
381+
u32 features)
382+
{
383+
switch (version) {
384+
case 0:
385+
break;
386+
case GLINK_VERSION_1:
387+
glink->features &= features;
388+
/* FALLTHROUGH */
389+
default:
390+
qcom_glink_send_version_ack(glink);
391+
break;
392+
}
393+
}
394+
395+
/**
396+
* qcom_glink_receive_version_ack() - receive negotiation ack from remote system
397+
*
398+
* @glink: pointer to transport interface
399+
* @r_version: remote version response
400+
* @r_features: remote features response
401+
*
402+
* This function is called in response to a local-initiated version/feature
403+
* negotiation sequence and is the counter-offer from the remote side based
404+
* upon the initial version and feature set requested.
405+
*/
406+
static void qcom_glink_receive_version_ack(struct qcom_glink *glink,
407+
u32 version,
408+
u32 features)
409+
{
410+
switch (version) {
411+
case 0:
412+
/* Version negotiation failed */
413+
break;
414+
case GLINK_VERSION_1:
415+
if (features == glink->features)
416+
break;
417+
418+
glink->features &= features;
419+
/* FALLTHROUGH */
420+
default:
421+
qcom_glink_send_version(glink);
422+
break;
423+
}
424+
}
425+
365426
static int qcom_glink_rx_defer(struct qcom_glink *glink, size_t extra)
366427
{
367428
struct glink_defer_cmd *dcmd;
@@ -908,9 +969,10 @@ static void qcom_glink_work(struct work_struct *work)
908969

909970
switch (cmd) {
910971
case RPM_CMD_VERSION:
911-
qcom_glink_send_version_ack(glink);
972+
qcom_glink_receive_version(glink, param1, param2);
912973
break;
913974
case RPM_CMD_VERSION_ACK:
975+
qcom_glink_receive_version_ack(glink, param1, param2);
914976
break;
915977
case RPM_CMD_OPEN:
916978
qcom_glink_rx_open(glink, param1, msg->data);
@@ -931,6 +993,7 @@ static void qcom_glink_work(struct work_struct *work)
931993
}
932994

933995
struct qcom_glink *qcom_glink_native_probe(struct device *dev,
996+
unsigned long features,
934997
struct qcom_glink_pipe *rx,
935998
struct qcom_glink_pipe *tx)
936999
{
@@ -946,6 +1009,8 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,
9461009
glink->tx_pipe = tx;
9471010
glink->rx_pipe = rx;
9481011

1012+
glink->features = features;
1013+
9491014
mutex_init(&glink->tx_lock);
9501015
spin_lock_init(&glink->rx_lock);
9511016
INIT_LIST_HEAD(&glink->rx_queue);

‎drivers/rpmsg/qcom_glink_native.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#ifndef __QCOM_GLINK_NATIVE_H__
1515
#define __QCOM_GLINK_NATIVE_H__
1616

17+
#define GLINK_FEATURE_INTENT_REUSE BIT(0)
18+
#define GLINK_FEATURE_MIGRATION BIT(1)
19+
#define GLINK_FEATURE_TRACER_PKT BIT(2)
20+
1721
struct qcom_glink_pipe {
1822
size_t length;
1923

@@ -31,6 +35,7 @@ struct qcom_glink_pipe {
3135
struct qcom_glink;
3236

3337
struct qcom_glink *qcom_glink_native_probe(struct device *dev,
38+
unsigned long features,
3439
struct qcom_glink_pipe *rx,
3540
struct qcom_glink_pipe *tx);
3641
void qcom_glink_native_remove(struct qcom_glink *glink);

‎drivers/rpmsg/qcom_glink_rpm.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ static int glink_rpm_probe(struct platform_device *pdev)
302302
writel(0, tx_pipe->head);
303303
writel(0, rx_pipe->tail);
304304

305-
glink = qcom_glink_native_probe(&pdev->dev, &rx_pipe->native,
305+
glink = qcom_glink_native_probe(&pdev->dev,
306+
0,
307+
&rx_pipe->native,
306308
&tx_pipe->native);
307309
if (IS_ERR(glink))
308310
return PTR_ERR(glink);

‎drivers/rpmsg/qcom_glink_smem.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent,
284284
*tx_pipe->head = 0;
285285

286286
glink = qcom_glink_native_probe(dev,
287+
0,
287288
&rx_pipe->native, &tx_pipe->native);
288289
if (IS_ERR(glink)) {
289290
ret = PTR_ERR(glink);

0 commit comments

Comments
 (0)