This is a third conditional sentence describing an unreal past situation. The structure is: If + past perfect (had known) + would have + past participle (have helped). 'Had known' is correct because it refers to a past hypothetical condition. 'Knew' or 'have known' don't fit this conditional structure.